📜  postgres 杀死 db 上的连接 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:08.690000             🧑  作者: Mango

代码示例1
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'
    ;