Skip to content

Instantly share code, notes, and snippets.

@ryanpadilha
Last active March 25, 2016 22:07
Show Gist options
  • Save ryanpadilha/ede0bb6d24517dbb2930 to your computer and use it in GitHub Desktop.
Save ryanpadilha/ede0bb6d24517dbb2930 to your computer and use it in GitHub Desktop.
Oracle constraint verification
-- SQL command
SELECT CPAI.OWNER, CPAI.CONSTRAINT_NAME, CPAI.CONSTRAINT_TYPE, CPAI.TABLE_NAME,
CPAI.STATUS, CPAI.R_CONSTRAINT_NAME, COL.COLUMN_NAME,
(
SELECT F.TABLE_NAME FROM DBA_CONSTRAINTS F
WHERE F.CONSTRAINT_NAME = CPAI.R_CONSTRAINT_NAME
) TABLE_NAME_FILHA
FROM DBA_CONSTRAINTS CPAI, DBA_CONS_COLUMNS COL
WHERE CPAI.CONSTRAINT_NAME = COL.CONSTRAINT_NAME
AND CPAI.OWNER = '&PROPRIETARIO'
AND CPAI.TABLE_NAME = '&TABELA'
AND CPAI.CONSTRAINT_TYPE = 'R'
GROUP BY CPAI.OWNER, CPAI.CONSTRAINT_NAME, CPAI.CONSTRAINT_TYPE,
CPAI.TABLE_NAME, CPAI.STATUS, CPAI.R_CONSTRAINT_NAME, COL.COLUMN_NAME
ORDER BY COL.COLUMN_NAME;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment