Terminating A Connection
$ dropdb sample_db
dropdb: database removal failed: ERROR: database "sample_db" is being accessed by other users
DETAIL: There is 1 other session using the database.> select pg_terminate_backend(12345);
pg_terminate_backend
----------------------
tselect pg_terminate_backend(pg_stat_activity.pid)
from pg_stat_activity
where pg_stat_activity.datname = 'sample_db'
and pid <> pg_backend_pid();
pg_terminate_backend
----------------------
tLast updated