VB and VBA Users Source Code: Oracle Tip: Managing Table Constraints (inc. Foreign Key Constraints)
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Oracle Tip: Managing Table Constraints (inc. Foreign Key Constraints)
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, March 15, 2005
Hits:
1820
Category:
Database/SQL/ADO
Article:
Below are two useful pieces of SQL for managing table constraints. The first lists the constaints of a specific table: SELECT Constraint_name, Constraint_type, Table_name, R_constraint_name FROM User_constraints WHERE Table_name = 'My_Table_Name' To drop a Primary Key constaint that is reference by Foreign Keys use the following: ALTER TABLE My_Table_Name DROP CONSTRAINT PK_My_Table_Name CASCADE To disable all session table constraints, use this (with CAUTION): BEGIN FOR i in (select constraint_name, table_name from user_constraints) LOOP execute immediate 'alter table '||i.table_name||' disable constraint '||i.constraint_name||''; END LOOP; END;
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder