May 14, 2021

PostgreSQL psql utility

psql   PostgreSQL interactive terminal

psql --help
U - Username
d - Database name
W - to force super user to provide password
h - Hostname
p - port number
f - file path

psql --version
psql testdb
psql -U postgres
psql -U postgres -d testdb

psql -p 5301
psql -p 5444 -U postgres
psql -p 5302 -U postgres -E
psql -p 5434 -U d3_user postgres
psql -p 5432 testdb -f /tmp/export.sql

psql -U postgres -f backupfile.sql
psql -U postgres --set ON_ERROR_STOP=on -f backupfile
psql -U postgres -d devdb -f objects.sql
psql -U postgres -d devdb < /home/pgsql/devdb_backup.sql
psql -h localhost -p 5301 -U test -d postgres

psql -p 5311 -c "SELECT max(distinct date(timestamp)) FROM audit_events" go_exnts
psql -c "CHECKPOINT"      -- For forceful checkpoint
psql --port=5432 --host=localhost --dbname=nw --username=postgres
psql -c "select * from orders" -t -o orders.txt store dbuser1


Related PostgreSQL Articles:  Postgres pg_ctl commands   pg_restore utility

No comments:

Post a Comment