Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: A Primary Key and Foreign key
You can disable all foreign key constraints
on a schema using script like the following:
spool x.sql
select 'alter table '||table_name||' disable constraint '||constraint_name
||';'
from user_constraints where status = 'ENABLED' and constraint_type = 'R';
spool off
set feedback on
@@x
-- just check if all constraints were disabled
select status,count(*) from user_constraints
group by status;
of course there's another script to turn the constraints on again
spool x.sql
select 'alter table '||table_name||' enable constraint '||constraint_name
||';'
from user_constraints where status = 'DISABLED' and constraint_type = 'R';
spool off
set feedback on
@@x
-- just check if all constraints were enabled
select status,count(*) from user_constraints
group by status;
I suggest not to disable PK, nor CHECK constraints - You'll have better view on the load process and avoid duplicates or inapropriate values.
Remember about disabling triggers also!!!!
Best Regards,
Robert
--
Robert Liziniewicz C.I. HTS-ComArch Robert.Liziniewicz_at_ci.comarch.pl ul. Ujastek 10, Krakow tel. (+48 12) 644-66-31 (+48 601) 47-86-81Received on Tue Dec 01 1998 - 10:19:12 CST
![]() |
![]() |