Pages

Saturday, June 11, 2011

Finding FK for a Parent table



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_type in ('P','U') and table_name='T_LOOKUP');


select 'alter table '||a.owner||'.'||a.table_name||
            ' disable constraint '||a.constraint_name||';'
            from all_constraints a, all_constraints b
            where a.constraint_type = 'R'
            and a.r_constraint_name = b.constraint_name
            and a.r_owner  = b.owner
            and b.table_name = 'T_LOOKUP';

No comments:

Post a Comment