postgres查看是否锁表
select oid from pg_database where datname = ‘库名’
select oid from pg_class where relname=‘表名’ #注意pg_class不是全局,需要切换到相应的库里去查询
记住2个oid的值
select pid from pg_locks where relation = oid的值
select datname,query,pid from pg_stat_activity where pid in (pid的值) 查看锁的类型
select pg_terminate_backend(pid) 释放锁
select pid, state, usename, query, query_start
from pg_stat_activity
where pid in (
select pid from pg_locks l
join pg_class t on l.relation = t.oid
and t.relkind = 'r'
);