You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
934 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