๐ฆ Database-wide Info
| Command | Description |
|---|---|
\l |
List all databases |
\c dbname |
Connect to a database |
\conninfo |
Show current connection info |
\dtS |
List system tables |
\dconfig |
Show configuration parameters |
๐ Schemas
| Command | Description |
|---|---|
\dn |
List all schemas |
\dn+ |
List schemas with access privileges |
\df |
List all functions |
\df+ |
List functions with details |
๐ Tables and Views
| Command | Description |
|---|---|
\dt |
List tables |
\dt+ |
List tables with size and description |
\dv |
List views |
\dv+ |
List views with extended info |
\di |
List indexes |
\di+ |
List indexes with size and info |
\ds |
List sequences |
\ds+ |
List sequences with extended info |
\d table |
Describe table columns, types, modifiers |
\d+ table |
Describe table with additional storage info |
\d table.col |
Show a specific column info |
๐ Relations and Dependencies
| Command | Description |
|---|---|
\d table |
Show foreign keys, primary keys, constraints |
\dFk |
Show foreign key constraints |
\dP |
Show primary key constraints |
\dC |
Show check constraints |
\d table |
Shows relations (child/parent tables) |
๐ง Functions, Procedures, Triggers
| Command | Description |
|---|---|
\df |
List user-defined functions |
\dfS |
List system functions |
\df+ |
Function definitions with parameters |
\df function_name |
Details of a specific function |
\dy |
List event triggers |
\dT |
List custom data types |
\dL |
List procedural languages |
๐ Roles, Users, and Permissions
| Command | Description |
|---|---|
\du |
List all roles/users |
\du+ |
List roles with attributes |
\dg |
Alias for \du |
\z |
List access privileges on tables/views |
\dp |
Same as \z, shows GRANT info |
๐ Types, Domains, and Enums
| Command | Description |
|---|---|
\dT |
List all types |
\dT+ |
List types with descriptions |
\dT enum_type |
List enum values |
\dD |
List domains |
๐ Indexes and Constraints
| Command | Description |
|---|---|
\di |
List indexes |
\di+ |
Indexes with size and definition |
\d table |
Shows unique, check, FK constraints |
โณ Sequences
| Command | Description |
|---|---|
\ds |
List all sequences |
\ds+ |
Show sequence details |
๐ ๏ธ Extensions and System Info
| Command | Description |
|---|---|
\dx |
List installed extensions |
\dx+ |
Extension details |
\dfS |
List system functions |
\do |
List all operators |
๐ Search and Pattern Matching
| Command | Description |
|---|---|
\d *term* |
Pattern search in table names |
\df *func* |
Pattern match functions |
\di *index* |
Match index names |
\dT *type* |
Match types |
๐งจ Other Useful Meta-Commands
| Command | Description |
|---|---|
\! |
Run shell command |
\q |
Quit psql |
\? |
Help on all meta-commands |
\h |
SQL syntax help (e.g. \h SELECT) |