Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 958
  • Last Modified:

Disable\Enable Constraints and Triggers for a Schema

Hello,

Can anyone please provide a method or script to easily Disable\Enable Constraints and Triggers for a Schema?

Thanks,

Michael4606
0
michael4606
Asked:
michael4606
1 Solution
 
MikeOM_DBACommented:

You actually only need to disable the foreign key (and unique key maybe) constraints.

You could code a PL/SQL procedure with dynamic SQL or do something like this:

Set Pages 0 Lin 120 Trims On Feed Off Echo Off
Spo Dis_Cons.Sql
Select 'Alter Table '||Table_Name
    ||' Disable Constraint '||Constraint_Name||';'
  From User_Constraints Where Constraint_Type In ('R', 'U');
Spo Off
@Dis_Cons
Spo Dis_Trig.Sql
Select 'Alter Trigger '||Trigger_Name||' Disable;'
  From User_Triggers;
Spo Off
@Dis_Trig

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now