SELECT
D.TABLE_NAME "Table name",
D.CONSTRAINT_NAME "Constraint name",
DECODE(D.CONSTRAINT_TYPE,
'P','Primary Key',
'R','Foreign Key',
'C','Check/Not Null',
'U','Unique',
'V','View Cons') "Type",
D.SEARCH_CONDITION "Check Condition",
P.TABLE_NAME "Ref Table name",
P.CONSTRAINT_NAME "Ref by",
M.COLUMN_NAME "Ref col",
M.POSITION "Position",
P.OWNER "Ref owner"
FROM
DBA_CONSTRAINTS D
LEFT JOIN
DBA_CONSTRAINTS P
ON (D.R_OWNER=P.OWNER AND
D.R_CONSTRAINT_NAME=P.CONSTRAINT_NAME)
LEFT JOIN
DBA_CONS_COLUMNS M
ON (D.CONSTRAINT_NAME=M.CONSTRAINT_NAME)
WHERE
D.TABLE_NAME
IN (
SELECT TABLE_NAME FROM DBA_TABLES WHERE
OWNER=UPPER(:b1)
UNION ALL
SELECT VIEW_NAME FROM DBA_VIEWS WHERE OWNER=UPPER(:b1)
)
ORDER BY 1,2,3
D.TABLE_NAME "Table name",
D.CONSTRAINT_NAME "Constraint name",
DECODE(D.CONSTRAINT_TYPE,
'P','Primary Key',
'R','Foreign Key',
'C','Check/Not Null',
'U','Unique',
'V','View Cons') "Type",
D.SEARCH_CONDITION "Check Condition",
P.TABLE_NAME "Ref Table name",
P.CONSTRAINT_NAME "Ref by",
M.COLUMN_NAME "Ref col",
M.POSITION "Position",
P.OWNER "Ref owner"
FROM
DBA_CONSTRAINTS D
LEFT JOIN
DBA_CONSTRAINTS P
ON (D.R_OWNER=P.OWNER AND
D.R_CONSTRAINT_NAME=P.CONSTRAINT_NAME)
LEFT JOIN
DBA_CONS_COLUMNS M
ON (D.CONSTRAINT_NAME=M.CONSTRAINT_NAME)
WHERE
D.TABLE_NAME
IN (
SELECT TABLE_NAME FROM DBA_TABLES WHERE
OWNER=UPPER(:b1)
UNION ALL
SELECT VIEW_NAME FROM DBA_VIEWS WHERE OWNER=UPPER(:b1)
)
ORDER BY 1,2,3
No comments:
Post a Comment