Ejemplo 1: ver y eliminar conexiones de postgresql a la base de datos
/* 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)
Ejemplo 2: postgres matando conexiones en db
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 = 'database_name'
;
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)