PostgreSql查看当前表被哪些引用作参考表
-- pg_CONSTRAINT.contype : p(主键), f(外键), u(唯一), c(检查)
-- 查看当前表ID
SELECT oid, relname FROM pg_class WHERE relname = ‘syslogfilter‘;
-- 查看引用当前表ID作参考表的主外键约束信息
SELECT * FROM pg_CONSTRAINT WHERE confrelid = ‘24935‘;
-- 查看那些外键的名称
SELECT oid, relname FROM pg_class WHERE oid in
(
SELECT conrelid FROM pg_CONSTRAINT WHERE confrelid = ‘24935‘
);
时间: 2024-10-02 10:47:55