Constraints - Disables all the foreign keys referencing a specific table for the
set echo off
--
--  Name: disablefk1.sql
--
--  Description: Constraints - Disables all the foreign keys referencing a specific table for the current user/schema login
--
--  Compatability: 7.3 and above
--
--  Usage: @disablefk1 table_name
--
set termout off
set verify off
set doc off
set feedback off
set recsep off
set pagesize 0
--
define lsize=133
set linesize &&lsize
--
define out_file=disablefk1.ddl
spool &&out_file
--
SELECT 'alter table '||fk.owner||'.'||fk.table_name||' disable constraint '||fk.constraint_name||';'
from  user_constraints fk, user_constraints pk
WHERE   fk.r_constraint_name = pk.constraint_name and
        fk.constraint_type = 'R' and
        (pk.constraint_type = 'P' or pk.constraint_type = 'U') and
        fk.r_owner = pk.owner and
        (pk.table_name  = upper('&&1'))
ORDER BY  fk.constraint_name ;
--
spool off
set doc off
set feedback on
set pagesize 30
set termout on
set echo on
start &&out_file
-- exit