Create docker container.
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
Install postgresql client into mac.
brew install postgresql
Connect to postgresql.
psql -h 127.0.0.1 -U postgres
end enter password mysecretpassword
.
List databases.
postgres=# \l
Create a database.
create database database_name;
Delete a database.
postgres=# drop database database_name;
Select a database.
postgres=# \c database_name
Create a table.
postgres=# create table table_name (column_name1 column_type, column_name22 column_type);
Example of creating a database.
postgres=# create table test_table(id integer, name varchar(20);
List tables.
postgres=# \dt
Show table schema
postgres=# \d table_name
# or
postgres=# \d+ table_name