Skip to content

Instantly share code, notes, and snippets.

@icirellik
Created May 2, 2016 17:22
Show Gist options
  • Save icirellik/ec0362aa0ad7b254f6e291d412b0be50 to your computer and use it in GitHub Desktop.
Save icirellik/ec0362aa0ad7b254f6e291d412b0be50 to your computer and use it in GitHub Desktop.
PostgreSQL Commands
-- Query a parameter
SHOW max_connections;
RESET max_connections;
SHOW ALL;
SELECT * FROM pg_settings;
SELECT *
FROM pg_settings
WHERE name = 'max_connections';
-- Force drop db with active connections > 9.2
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
-- Show active connections
SELECT * FROM pg_stat_activity;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment