질문에 대한 답변은 아닐런지 모르겠네요....
[오라클 데이타베이스]
참조하는가
참조 당하는가로 분류해 볼 수 있겠네요
아래 쿼리 2개를 활용해 보세요
1.나를 어느 테이블에서 참조하고 있는지
SELECT * FROM (SELECT REF_TBL.CONSTRAINT_NAME CNST_NAME, IND_COL.COLUMN_NAME, IND_COL.COLUMN_POSITION COL_PSTN, FOR_TBL.TABLE_NAME FROM SYS.ALL_CONSTRAINTS FOR_TBL, SYS.ALL_CONSTRAINTS REF_TBL, SYS.ALL_IND_COLUMNS IND_COL WHERE FOR_TBL.OWNER = 'CNSONE' //---------오너명 AND FOR_TBL.TABLE_NAME = 'PI200M' //----------테이블명 AND FOR_TBL.CONSTRAINT_TYPE = 'P' AND FOR_TBL.OWNER = REF_TBL.R_OWNER AND FOR_TBL.CONSTRAINT_NAME = REF_TBL.R_CONSTRAINT_NAME AND FOR_TBL.OWNER = IND_COL.TABLE_OWNER AND FOR_TBL.TABLE_NAME = IND_COL.TABLE_NAME AND FOR_TBL.CONSTRAINT_NAME = IND_COL.INDEX_NAME) WHERE 1 = 1 ORDER BY CNST_NAME ASC, COL_PSTN ASC 2.내가 어느테이블을 참조하고 있는지 확인 SELECT * FROM (SELECT FORTBL.CONSTRAINT_NAME CNST_NAME, IDXTBL.COLUMN_NAME, IDXTBL.COLUMN_POSITION COL_PSTN, REFTBL.TABLE_NAME FROM SYS.ALL_CONSTRAINTS FORTBL, SYS.ALL_CONSTRAINTS REFTBL, SYS.ALL_IND_COLUMNS IDXTBL WHERE FORTBL.OWNER = 'CNSONE' //------------오너명 AND FORTBL.TABLE_NAME = 'PI200M' //----------테이블명 AND FORTBL.CONSTRAINT_TYPE = 'R' AND REFTBL.CONSTRAINT_TYPE = 'P' AND REFTBL.OWNER = FORTBL.R_OWNER AND REFTBL.CONSTRAINT_NAME = FORTBL.R_CONSTRAINT_NAME AND IDXTBL.INDEX_OWNER = REFTBL.OWNER AND IDXTBL.INDEX_NAME = REFTBL.INDEX_NAME) WHERE 1 = 1 ORDER BY CNST_NAME ASC, COL_PSTN ASC
SELECT PRIOR a.owner fk_owner , PRIOR a.constraint_name fk_constraint_name , PRIOR a.table_name fk_table_name , PRIOR b.column_name fk_column_name , a.owner pk_owner , a.constraint_name pk_constraint_name , a.table_name pk_table_name , b.column_name pk_column_name FROM user_constraints a , (SELECT owner, constraint_name , LISTAGG(column_name, ',') WITHIN GROUP(ORDER BY position) column_name FROM user_cons_columns GROUP BY owner, constraint_name ) b WHERE a.owner = b.owner AND a.constraint_name = b.constraint_name AND CONNECT_BY_ISLEAF = 1 START WITH a.constraint_type = 'R' CONNECT BY PRIOR a.r_owner = a.owner AND PRIOR a.r_constraint_name = a.constraint_name ;