2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-03 15:40:17 +00:00
cheat.sheets/sheets/_psql/shell
2018-01-07 11:42:08 +00:00

49 lines
918 B
Plaintext

# Connect to a specific database
\c database_name
# To quite the psql
\q
# List all databases in the PostgreSQL database server
\l
# List all schemas
\dn
# List all stored procedures and functions
\df
# List all views
\dv
# Lists all tables in a current database
\dt
# Get more information on tables in the current database
\dt+
# Get detailed information on a table
\d+ table_name
# Show a stored procedure or function code
\df+ function_name
# Show query output in the pretty-format
\x
# List all users
\du
# Export table into CSV file
\copy <table_name> TO '<file_path>' CSV
# Export table, only specific columns, to CSV file
\copy <table_name>(<column_1>,<column_1>,<column_1>) TO '<file_path>' CSV
# Import CSV file into table
\copy <table_name> FROM '<file_path>' CSV
# Import CSV file into table, only specific columns
\copy <table_name>(<column_1>,<column_1>,<column_1>) FROM '<file_path>' CSV