Constraints [message #242865] |
Tue, 05 June 2007 05:58 |
sussudio
Messages: 30 Registered: March 2005 Location: London
|
Member |
|
|
I need a quick way to drop all the contraints on a set of tables so I can import free from errors. Is there a quick way or will I just have to go through each table ans disable the contraints.
Many thanks for any help that you give.
|
|
|
|
Re: Constraints [message #242986 is a reply to message #242866] |
Tue, 05 June 2007 12:01 |
jrich
Messages: 35 Registered: February 2006
|
Member |
|
|
DECLARE
stmt varchar2(1000);
c_rec all_constraints%ROWTYPE;
BEGIN
/* Remove foreign keys */
FOR c_rec IN
(select *
from all_constraints
where owner='xxx'
and table_name like 'yyy%'
and constraint_type = 'R')
LOOP
stmt := ' ALTER TABLE ' || c_rec.owner ||
'.' || c_rec.table_name ||
' DROP CONSTRAINT ' || c_rec.constraint_name;
execute immediate stmt;
END LOOP;
This gets rid of the foreign keys. Modify the owner and table_name predicates to select specific tables. Change the contraint_type predicate to select other constraint types (C = check, U = unique, P = primary key).
JR
[Updated on: Tue, 05 June 2007 12:01] Report message to a moderator
|
|
|