Baishun's Space
Home
Diary
Flutter
Vim
Novel
Backend
Others
Some Psql command
By Baishun on May 8, 2022
X
Facebook
Email
Y Combinator
LinkedIn
Reddit
WhatsApp
Below are some useful postgre sql commands:
Connect to a Database: “psql -d db_name -U user_name”.
Check Postgres Version: “SELECT VERSION();”.
List All Databases: “\l”.
Access or Switch a Database: “\c db_name”.
List All Tables: “\dt”.
Describe All Tables: “\d”.
Describe a Specific Table: “\d tab_name”.
List All Schemas: “\dn”.
List All Views: “\dv”.
List All Functions: “\df”.
List All Users: “\du”.
Show Commands History: “\s”
Save Query’s Results to a Specific File: “\o file_name”.
Run psql Commands/queries From a Particular File: “\i file_name”.
Execute Previous Command: “\g”.
Show Query Execution Time: “\timing”.
Get Output in HTML Format: “\H”.
Align Columns Output: “\a”.
Get Help: “\h”.
Get All psql Commands: “?”.
Clear Screen: “! cls”.
Quit psql: “\q”.
For business cooperation or you have any questions, please send email to :
lecy.cc.app@gmail.com
© Copyright 2025 by Baishun Space. Built with ♥ by
Lecy
. Origin theme of this blog is from
ixartz
. Social Icons are copied from
astro-social-share