# Install via Homebrew
brew install postgresql
# Have launchd start postgresql now and restart at login
brew services start postgresql
createdb my-db
psql
is the PostgreSQL interactive terminal.
# In bash
# List all databases
psql --list
# Connect to the database named "my-db"
psql my-db
-- In psql terminal
-- Main help menu
help
-- Help with psql commands
\?
-- Help with SQL commands
\h
-- Quit
\q
-- List all databases
\l
-- List all tables in current database
\d
\d+ -- More detail
-- Describe table (also works with view, sequence, or index)
\d table_name
\d+ table_name -- More detail
-- View full table contents
TABLE table_name;