-- 查看对应表都有哪些锁 select locktype,pid,relation,mode,granted,*from pg_locks where relation in (select oid from pg_class where relname='table_name'); select pg_terminate_backend('进程ID');
-- 测试
-- 终止所有被激活的锁 select pg_terminate_backend(pid) from pg_stat_activity where state ='active' and pid != pg_backend_pid() and pid in (select a.pid from pg_locks a join pg_class b on a.relation = b.oid wherelower(b.relname) ='news_content');