given a database named db:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='db'
AND state = 'idle in transaction'
given a database named db:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='db'
AND state = 'idle in transaction'