Install with Homebrew:

$ brew install postgresql

Start postgresql as a service

$ brew services start postgresql

Enter Queries using psql:

$ psql postgres

Create database:

$ CREATE DATABASE database_name

Add table:

$ ALTER DATABASE database_name

(press enter, and do not end with a semi-colon. This will make it possible to enter multiple lines).

$ ADD COLUMN id integer;

Set id as primary key:

$ ALTER TABLE table_name

(press return)

$ ADD PRIMARY KEY (column_name);