published under license Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)copy! share!
posted in category Systems Software / Postgres
posted at 02. Jun '20
last updated at 28. Mar '22
Postgres psql
Commands
- list databases:
\l
- connect to database / switch database:
\c DB_NAME
- list tables:
\dt
- foreign servers:
\des+
- foreign tables:
\det+
- sequences:
\ds+
- trigger functions:
\dft
- triggers:
\dS <tablename>
- (trigger) function source:
\df+ <functionname>
- list users:
\du
- more commands:
\?
- SQL help:
\h
+
means more details, \d
describe I guess, usually database need to be selected before a command to see data. Command won’t error out if database is not selected.
- list hanged commands in case of race conditions:
postgres=# select * from pg_stat_activity;
Add Comment