Attach to a docker container
docker exec -it project_postgres_1 bash
Switch to postgres user
root@58a96e78e770:/# su postgres
$
Enter to psql
$ psql
psql (9.6.3)
Type "help" for help.
postgres=#
List databases
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------+----------+----------+------------+------------+-----------------------
project_name | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
postgres-#
Remove a db
drop database project_name;
create a db
create database project_name;
Connect to a database
postgres-# \c project_name
You are now connected to database "project_name" as user "postgres".
project_name-#
List tables
project_name-# \t
Tuples only is on.
project_name-#