Psql
The psql(1) utility is a simple, terminal-based client for PostgreSQL databases.
Contents
Installation
psql(1) is not typically packaged with the core components. For Arch, install the postgresql-libs package. For Alpine or Debian, install the postgresql-client package.
Usage
To open a REPL with a local PostgreSQL database, try:
psql --username=postgres
Aside from SQL queries, there are special commands available in the REPL.
Commands
Command |
Meaning |
\c [DATABASE] |
Connect to [DATABASE] |
\d |
List tables and relations |
\dt |
List all tables |
\di |
List all indices |