Useful Postgresql commands/sqls for beginners

The PostgreSQL cluster is in recovery (or is a streaming replication standby). You can find out if that is the case by running
SELECT pg_is_in_recovery();
The parameter default_transaction_read_only is set to on. Diagnose with
SHOW default_transaction_read_only;
The current transaction has been started with. You can find out if that is the case using the undocumented parameter
SHOW transaction_read_only;
where is pgdata?
SHOW data_directory;
Replication user is active?
select * from pg_stat_activity where usename = 'replicator';

PSQL Listing Commands


\x on; --extended display
\c db; --connect to database
\du+; --list users
\dt+ schema.tablename; --lists tables
\df+ schema.func/procname;
\d+  schema.tablename; -- gives description of table

Leave a Reply

Your email address will not be published. Required fields are marked *

44 + = 50