End-to-End Kubernetes Security
April 21, 2023
June 27, 2023

The table below contains some essential commands for PostgreSQL.

FunctionCommand SyntaxComments
Connect to a database under a specific userpsql -d database -U user -WReplace database and user
Connect to a database on another hotspsql -h host -d database -U user -WReplace the host, database and user
Switch connection\c dbname usernameReplace with the name of the database & the username. If the username is left empty, it will automatically connect with current user
List available databases\l
List available schemas\dn
List available tables\dtTo list tables from all schemas, add *.*. To list from a specific schema, add schema_name.*(ex. \dt information_schema.*
Describe a table\d table_name
List available views\dv
List indexes\di
List data types\dT+
List users\duThis command will also list the roles of the users
Access command history\sTo save the command history to a file, specify the filename after the command
Get help on commands\?This will show a list with all the commands available in PostgreSQL.
Get help on a specific statement\h statementThis will show you details about a specific PostgreSQL statement. (ex. \h CREATE TABLE)
Quit\q
Postgres Cheat Sheet

Leave a Reply

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