2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-15 06:12:59 +00:00
cheat.sheets/sheets/psql
Igor Chubin 0adbf03348 Fix comment length in all first-level cheat sheets
*  sheets/MegaCli
*  sheets/az
*  sheets/azure
*  sheets/blktrace
*  sheets/emacs
*  sheets/exim
*  sheets/go
*  sheets/ipython
*  sheets/jq
*  sheets/nmap
*  sheets/perl
*  sheets/psql
*  sheets/redis
*  sheets/sed
*  sheets/smartctl
*  sheets/solidity
*  sheets/yq_v4
2020-11-22 13:10:48 +01:00

29 lines
805 B
Plaintext

# psql
# PostgreSQL command-line client.
# Connect to database.
# It connects to localhost using default port 5432
# with default user as currently logged in user
psql database
# Connect to database on given server host running on given port
# with given username, without a password prompt
psql -h host -p port -U username database
# Connect to database; user will be prompted for password
psql -h host -p port -U username -W database
# Execute a single SQL query or PostgreSQL command
# on the given database (useful in shell scripts)
psql -c 'query' database
# Execute commands from a file on the given database
psql database -f file.sql
# See also:
# pg_dump, pg_restore, pg_top
# PostgreSQL cheat sheets at /psql/
# list of pages: /psql/:list
# search in pages: /psql/~keyword