๐Ÿ“ฆ 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)

Leave a Reply

Your email address will not be published. Required fields are marked *