DEV Community

theBridge2
theBridge2

Posted on

PostgreSQL command line psql cheat sheet

Tools Overview

postgres = open source relational database software
psql = command line tool to connect to postgres
pgAdmin = web based tool front end to psql - not discussing here

Image description

This cheat sheet is for psql. Other 3rd party tools exist for connecting to postgres databases. (Dbeaver is a popular choice)

Postgres cmd line tool psql

Official docs
https://www.postgresql.org/docs/current/app-psql.html

Command Description
psql --help list help
psql --username=postgres login to postgres cmd line

When logged in:

Command Description
\list print out list of databases
\c <db name> connect to a certain database
\dt show all tables in current schema
\df list functions of current database
\dv list views of current database
\du list users and roles
\q quit postgres cmd line

Top comments (0)