This is an old revision of the document!
psql -U postgres -tA -c 'SELECT datname FROM pg_database' | sort
db=... ; pghost=localhost psql -U postgres -h $pghost -t -A -c "SELECT datname, tup_inserted, tup_updated, tup_deleted FROM pg_stat_database WHERE datname='$db';"
psql -U postgres -t -c 'SELECT datname, pg_size_pretty(pg_database_size(datname)) AS size FROM pg_database' | sort
or
psql -U postgres -t -c "SELECT datname, format('%8s MB.', pg_database_size(datname)/1000000) FROM pg_database" | sort
psql -U postgres -tA -c "SHOW data_directory;"
psql -U postgres -c "SELECT name, setting FROM pg_settings WHERE setting LIKE '/%';"
or
psql -U postgres -c "SELECT name, setting FROM pg_settings WHERE name LIKE '%dir%' OR name LIKE '%file%';"
psql -U postgres -Pfooter=off -c \ "SELECT pid, datname, usename, concat_ws(' ', client_addr, client_hostname) AS host, \ application_name, wait_event_type, wait_event, state, query \ FROM pg_stat_activity WHERE NOT query LIKE '%SELECT % FROM pg_stat_activity%'"
db=my_database psql -U postgres -d $db -tA -c "SELECT table_name FROM information_schema.tables WHERE table_schema='public'" \ | while read -r tbl; do \ echo "==Table $tbl"; vacuumdb -U postgres -d $db -t "\"$tbl\"" --full --verbose 2>&1; done \ | tee -a vacuum-$db.log
Show current Resolve DB version
psql -U postgres -d zresolve_18 -c "SELECT version, time, remark FROM database_upgrade_log ORDER BY time"