📜  如何在 oracle 中查找表的约束 - SQL 代码示例

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

代码示例1
SELECT cons.OWNER             AS CHILD_OWNER,
       cons.TABLE_NAME         AS CHILD_TABLE,
       cons.CONSTRAINT_NAME AS CONSTAINT_NAME,
       cons.CONSTRAINT_TYPE AS CONSTRAINT_TYPE,
       col.OWNER             AS PARENT_OWNER,
       col.TABLE_NAME         AS PARENT_TABLE,
       col.COLUMN_NAME         AS COLUMN_NAME
FROM DBA_CONS_COLUMNS col, DBA_CONSTRAINTS cons
WHERE cons.R_OWNER = col.OWNER
  AND cons.R_CONSTRAINT_NAME = col.CONSTRAINT_NAME
  AND cons.TABLE_NAME = 'table_name';