Friday, May 9, 2014

Find any table is using PRIMARY KEY of a particular table

Find any FOREIGN KEY of a table is using PRIMARY KEY of another table



select * from all_cons_columns ucc, all_constraints uc where uc.constraint_name=ucc.constraint_name and uc.constraint_type='P' and uc.table_name = 'QP_ACTIVITY';


select * from all_cons_columns ucc, all_constraints uc where uc.constraint_name=ucc.constraint_name and uc.constraint_type='P' and uc.R_CONSTRAINT_NAME = 'QP_ACTIVITY';


select * from all_cons_columns ucc, all_constraints uc where uc.constraint_name=ucc.constraint_name and uc.constraint_type='R' and uc.table_name = ucc.owner and uc .owner='VSAC';


select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name from all_constraints 
where constraint_type='R' and r_constraint_name in (select constraint_name from all_constraints where constraint_name ='IDX_QP_ACTIVITY_PK'  and table_name='QP_ACTIVITY') and owner='VSAC';




No comments:

Post a Comment