Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I disable all table constraints

1057682Feb 20 2015 — edited Feb 21 2015

Hello All,

I am using Oracle SQL Developer

I am trying to disable all tables constraints so I can truncate the tables.

this is what I came up with but it is not working. Can someone please help me.

Thanks in advance,

Kevin

begin

  for cur in (select fk.owner, fk.constraint_name , fk.table_name

    from all_constraints fk, all_constraints pk

     where fk.CONSTRAINT_TYPE = 'R' and

           pk.owner = 'EIFILTERED' and

           fk.r_owner = pk.owner and

           fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME and

           pk.TABLE_NAME = 'ADDRESS', 'ALTERNATENAME', 'ACTIVITY', 'CASEEVENT'

           ) loop

    execute immediate 'ALTER TABLE "'||cur.owner||'"."'||cur.table_name||'" MODIFY CONSTRAINT "'||cur.constraint_name||'" DISABLE';

  end loop;

end;

This post has been answered by 23ai on Feb 21 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2015
Added on Feb 20 2015
4 comments
1,951 views