PostgreSQL Notes

Official Documentation and Tutorial

Install and run


brew install postgresql

Make sure that brew service is installed

brew tap homebrew/services

Start PostgreSQL as a background service: (will start automatically at login)

brew services start postgresql

stop and restart:

brew services stop [restart] postgresql


(to add)


Administrative front-ends

  • command line tool: psql
  • graphical tool: pgAdmin



Two basic modes

  • Connect to a database and entering SQL Commands
psql mydb

then execute commands for the database.

  • Use psql directly

    For example:

psql mydb -c "l"
psql mydb -c "[command]"

Basic meta-commands

  • list databases: l
  • list tables: dt
  • show columns: d table
  • quit: q

Full doc here.

Leave a Reply