Skip to content

Instantly share code, notes, and snippets.

@1duo
Created October 4, 2018 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1duo/16f6fa15f457c3fe5d4f4ecfa7c82809 to your computer and use it in GitHub Desktop.
Save 1duo/16f6fa15f457c3fe5d4f4ecfa7c82809 to your computer and use it in GitHub Desktop.
Adding a new table to Postgres database.
  • Start a new Postgres docker container (with or without mount Postgres data):
$ docker run --name pg1 -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
$ docker run --name pg1 -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d -v postgres-data:/var/lib/postgresql/data postgres
  • Step into the Postgres database docker container:
$ docker run -it --rm postgres psql -h <host-ip-address> -U postgres
  • Useful commands:
# List of relations

postgres=# \dt
             List of relations
 Schema |      Name      | Type  |  Owner   
--------+----------------+-------+----------
 public | dataset        | table | postgres
 public | model          | table | postgres
 public | net            | table | postgres
 ...
(10 rows)

# List of table contents

postgres=# select * from model;

     id |      tag      | framework  | owner   
--------+---------------+------------+-------
 5425d8 | tf-model-sept | tensorflow | kevin
 ...
(21 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment