gpt4 book ai didi

relational-database - PostgreSQL 查找包含表名的锁

转载 作者:行者123 更新时间:2023-12-04 12:07:09 26 4
gpt4 key购买 nike

我正在尝试查看正在发生的锁
我的 PostgreSQL 数据库中的特定表。

我看到有一个表叫 pg_locks

select * from pg_locks;

这似乎给了我一堆列,但有可能吗
找到关系,因为我看到其中一列是
关系oid。

我必须将它链接到哪个表才能获得关系名称?

最佳答案

这是 Remy 的查询,针对 Postgres 10 进行了调整:

select nspname, relname, l.* 
from pg_locks l
join pg_class c on (relation = c.oid)
join pg_namespace nsp on (c.relnamespace = nsp.oid)
where pid in (select pid
from pg_stat_activity
where datname = current_database()
and query != current_query());

关于relational-database - PostgreSQL 查找包含表名的锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37110149/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com