기본 콘텐츠로 건너뛰기

7월, 2014의 게시물 표시

오라클 FK 검색

SELECT     C.OWNER,     C.TABLE_NAME,     C.CONSTRAINT_NAME,     CC.COLUMN_NAME,     R.TABLE_NAME AS TN,     RC.COLUMN_NAME AS CN,     CC.POSITION FROM     DBA_CONSTRAINTS C,      DBA_CONSTRAINTS R,      DBA_CONS_COLUMNS CC,      DBA_CONS_COLUMNS RC WHERE         C.CONSTRAINT_TYPE = 'R' AND     C.OWNER ='사용자' --AND     C.TABLE_NAME = '테이블'--해당 태이블의 FK 검색 --AND     R.TABLE_NAME = '테이블'--해당 테이블의 PK가 엮인거 검색 AND     C.R_OWNER = R.OWNER AND     C.R_CONSTRAINT_NAME = R.CONSTRAINT_NAME AND     C.CONSTRAINT_NAME = CC.CONSTRAINT_NAME AND     C.OWNER = CC.OWNER AND     R.CONSTRAINT_NAME = RC.CONSTRAINT_NAME AND     R.OWNER = RC.OWNER AND     CC.POSITION = RC.POSITION ORDERBY C.OWNER, C.TABLE_NAME, C.CONSTRAINT_NAME, CC.POSITION