Answers for "is being accessed by other users DETAIL: There is 1 other session using the database."

SQL
1

view and kill postgresql connections to database

/* view connections */
SELECT * FROM pg_stat_activity;

/*-— Kill connections*/
SELECT
    pg_terminate_backend(pid)
FROM
    pg_stat_activity
WHERE
    -- don't kill my own connection!
    pid != pg_backend_pid()
    -- don't kill the connections to other databases
    AND datname = 'clinical_data';

/* kill a specific connection */     
select pg_terminate_backend(13337)
Posted by: Guest on April-14-2020
0

pgadmin postgres ERROR: database is being accessed by other users

PostgresVersion >=9.2

SELECT 
   pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE
   pg_stat_activity.datname = 'name_of_database_to_be_disconnected'
AND pid <> pg_backend_pid()
Posted by: Guest on November-28-2020

Code answers related to "is being accessed by other users DETAIL: There is 1 other session using the database."

Code answers related to "SQL"

Browse Popular Code Answers by Language