Postgres

Author: Tom Wragg

Postgres (PostgreSQL) is an open-source relational database management system.

Postgres supports multiple programming languages, replication, high availability, and offers extensive security measures.

 


Sections

 


Installation

Install postgresql

Install via homebrew

brew install postgresql

image

 


Configuration

To start up the database, run the following:

/opt/homebrew/opt/postgresql@14/bin/postgres -D /opt/homebrew/var/postgresql@14

image

 


Basic usage

Postgres provides the psql CLI to interact with the Postgres database.

psql -V

image

Login to the default database and select your username:-

psql -d postgres
SELECT current_user;

image

 


Advanced usage

Login with a specified username and database then list all databases and quit:-

psql -U wraggt -d postgres

List all databases:-

\l

Quit the session:-

\q

image