Máme v schéme MOJASCHEMA tabuľku MOJATABULKA.
Pohľad, ktorý zobrazí tabuľky, na ktoré sa odkazuje aktuálna tabuľka MOJATABULKA:
SELECT SRC_CC.OWNER AS SRC_OWNER, SRC_CC.TABLE_NAME AS SRC_TABLE, SRC_CC.COLUMN_NAME AS SRC_COLUMN, DEST_CC.OWNER AS DEST_OWNER, DEST_CC.TABLE_NAME AS DEST_TABLE, DEST_CC.COLUMN_NAME AS DEST_COLUMN, C.CONSTRAINT_NAME FROM ALL_CONSTRAINTS C INNER JOIN ALL_CONS_COLUMNS DEST_CC ON C.R_CONSTRAINT_NAME = DEST_CC.CONSTRAINT_NAME AND C.R_OWNER = DEST_CC.OWNER INNER JOIN ALL_CONS_COLUMNS SRC_CC ON C.CONSTRAINT_NAME = SRC_CC.CONSTRAINT_NAME AND C.OWNER = SRC_CC.OWNER WHERE C.CONSTRAINT_TYPE = 'R' AND DEST_CC.OWNER = 'MOJASCHEMA' AND DEST_CC.TABLE_NAME = 'MOJATABULKA' ORDER BY SRC_CC.TABLE_NAME;
Pohľad, ktorý zobrazí tabuľky, ktoré sa odkazujú na tabuľku MOJATABULKA:
SELECT A.OWNER||'.'||A.TABLE_NAME "REFERENCED TABLE", B.OWNER||'.'||B.TABLE_NAME "REFERENCED BY", B.CONSTRAINT_NAME "FOREIGN KEY" FROM ALL_CONSTRAINTS A, ALL_CONSTRAINTS B WHERE B.CONSTRAINT_TYPE = 'R' AND A.CONSTRAINT_NAME = B.R_CONSTRAINT_NAME AND B.TABLE_NAME='MOJATABULKA' ORDER BY A.OWNER||'.'||A.TABLE_NAME;
Pohľad, ktorý zobrazí všetky objekty, v ktorých sa tabuľka MOJATABULKA vyskytuje - je ich súčasťou:
SELECT * FROM ALL_DEPENDENCIES WHERE REFERENCED_TYPE = 'TABLE' AND REFERENCED_OWNER = 'MOJASCHEMA' AND REFERENCED_NAME IN ('MOJATABULKA') ORDER BY NAME;
Dúfam, že tieto pohľady budú nápomocné programátorom/vývojárom v prostredí ORACLE 11g.
S pozdravom.