List all connections to a specific database

PHOTO EMBED

Mon Sep 19 2022 00:57:38 GMT+0000 (UTC)

Saved by @aguest #sql

/*
Show all connections to the database
*/

SELECT
	datname, pid, usename, client_addr, client_port,
    query_start, state_change, state, query
FROM
	pg_stat_activity
WHERE
	datname = '<database name HERE>'
ORDER BY
	state_change DESC;
content_copyCOPY