Postgres commands

From UFP-UV Sakai Wiki

Jump to: navigation, search

Contents


Startup

su postgres
/usr/bin/pg_ctl -D /var/lib/pgsql/data start


Shutdown

su postgres
 
# Normal Stop: (all clients must be disconnected)
/usr/bin/pg_ctl -D /var/lib/pgsql/data stop
 
# Smart Stop:
/usr/bin/pg_ctl -D /var/lib/pgsql/data stop -m s
 
# Fast Stop:
/usr/bin/pg_ctl -D /var/lib/pgsql/data stop -m f
 
# Immediate Stop:
/usr/bin/pg_ctl -D /var/lib/pgsql/data stop -m i


Dump

su postgres
pg_dumpall > pg_dumpall_2010-09-29.sql


Query Postgres connections

su postgres
psql -U postgres template1
> SELECT * FROM pg_stat_activity;
Personal tools