SHOW wal_level;See summary for usage details.
Replication, transactions, FDWs, extensions, and specialized PostgreSQL workflows.
Foundational streaming replication and WAL commands.
SHOW wal_level;See summary for usage details.
SHOW max_wal_senders;See summary for usage details.
CREATE PUBLICATION app_pub FOR TABLE public.users, public.orders;See summary for usage details.
CREATE SUBSCRIPTION app_sub
CONNECTION 'host=primary-db port=5432 dbname=appdb user=replicator password=secret'
PUBLICATION app_pub;See summary for usage details.
ALTER SUBSCRIPTION app_sub REFRESH PUBLICATION;See summary for usage details.
SELECT * FROM pg_create_physical_replication_slot('standby_1');See summary for usage details.
SELECT pg_drop_replication_slot('standby_1');See summary for usage details.
SELECT pg_current_wal_lsn();See summary for usage details.
Commands for safe changes and contention debugging.
BEGIN;See summary for usage details.
COMMIT;See summary for usage details.
ROLLBACK;See summary for usage details.
SAVEPOINT before_step_two;See summary for usage details.
ROLLBACK TO SAVEPOINT before_step_two;See summary for usage details.
LOCK TABLE orders IN SHARE ROW EXCLUSIVE MODE;See summary for usage details.
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;See summary for usage details.
SET statement_timeout = '5s';See summary for usage details.
Useful federation commands when querying remote systems.
CREATE EXTENSION IF NOT EXISTS postgres_fdw;See summary for usage details.
CREATE SERVER analytics_remote
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host 'analytics-db', dbname 'analytics', port '5432');See summary for usage details.
CREATE USER MAPPING FOR appuser
SERVER analytics_remote
OPTIONS (user 'analytics_user', password 'secret');See summary for usage details.
IMPORT FOREIGN SCHEMA public FROM SERVER analytics_remote INTO analytics_fdw;See summary for usage details.
CREATE FOREIGN TABLE analytics_fdw.events (
event_id bigint,
payload jsonb
)
SERVER analytics_remote
OPTIONS (schema_name 'public', table_name 'events');See summary for usage details.
DROP SERVER analytics_remote CASCADE;See summary for usage details.
High-value extension and utility patterns beyond the basics.
CREATE EXTENSION IF NOT EXISTS pg_trgm;See summary for usage details.
CREATE INDEX idx_users_email_trgm ON public.users USING GIN (email gin_trgm_ops);See summary for usage details.
CREATE EXTENSION IF NOT EXISTS citext;See summary for usage details.
ALTER TABLE public.users ALTER COLUMN email TYPE citext;See summary for usage details.
CREATE EXTENSION IF NOT EXISTS pgstattuple;See summary for usage details.
SELECT * FROM pgstattuple('public.users');See summary for usage details.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";See summary for usage details.
SELECT uuid_generate_v4();See summary for usage details.