PostgreSQL

2024-02-13

Quickstart

Installation

$ sudo apt install postgresql

Become the postgres user.

$ su -l postgres

[Optional] Create User

$ createuser --interactive

[Optional] Create Database

$ createdb DBNAME

Start the primary database shell.

$ psql

psql shell

List all databases

=> \l

Connect to a particular database:

=> \c DBNAME

Show summary information about all tables in the current database:

=> \dt

List all users and their permission levels:

=> \du

Exit/quit the psql shell:

=> \q

Clear shell output

=> \! clear

Quirks with postgres

PostgreSQL interprets " as being quotes for identifiers, ' as being quotes for strings.