Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select constraint_name
- from dba_constraints
- where owner = '<SCHEMA_NAME>' and table_name = 'STUDENT' and constraint_type = 'P';
- select owner, table_name, constraint_name
- from dba_constraints
- where r_constraint_name = '<result from previous query>' and constraint_type = 'R';
- select owner, table_name, column_name
- from dba_cons_columns
- where constraint_name = '<constraint name from previous query>';
- SELECT fk.owner, fk.table_name, col.column_name
- FROM dba_constraints pk
- JOIN dba_constraints fk
- ON pk.constraint_name = fk.r_constraint_name
- AND fk.constraint_type = 'R'
- JOIN dba_cons_columns col
- ON fk.constraint_name = col.constraint_name
- WHERE pk.owner = :owner AND pk.table_name = 'STUDENT' AND pk.constraint_type = 'P';
- SELECT *
- FROM sys.all_constraints a
- INNER JOIN sys.all_constraints b
- ON a.constraint_name = b.constraint_name
- INNER JOIN sys.all_cons_columns c
- on c.constraint_name = b.constraint_name
- WHERE a.constraint_type = 'P'
- AND b.constraint_type = 'R'
- select fk.table_name, col.column_name
- from USER_constraints fk
- JOIN user_cons_columns col
- ON fk.constraint_name = col.constraint_name
- where constraint_type='R'
- and r_constraint_name in (
- select constraint_name
- from user_constraints
- where constraint_type in ('P','U')
- and table_name='TABLE_NAME'
- );
Add Comment
Please, Sign In to add comment