![]() |
||
Disabling Constraints : An Automated ProcessOracle automatically disable check constraints and referential constraints but Primary key, unique, and not null constraints remain in force till a disable command is used. In oracle (SQL*Plus), a one line command can do a thing like this:
SELECT 'alter table '||table_name||' disable constraint Test it first on screen to view the result, and then use the SPOOL command to flush the result to a file, do a quick editing, and then run the file. This should give you a nice command file for disabling constraints. To Disable 'anonymous' constraint: CREATE TABLE foo (bar NUMBER, baz NUMBER, UNIQUE (bar, baz)); ALTER TABLE foo DISABLE UNIQUE (bar, baz); To Disable named constraint: CREATE TABLE foo (bar NUMBER, baz NUMBER, CONSTRAINT uq_foo UNIQUE (bar, baz)); ALTER TABLE foo DISABLE CONSTRAINT uq_foo; To Disable a Check Constraint: ALTER TABLE table_name DISABLE CONSTRAINT constraint_name; In oracle, we can also use script for disabling constraints such as Primary key, unique, and not null:
SET PAGESIZE 0
SELECT 'ALTER TABLE ' || a.table_name || '
SPOOL OFF Disabling constraints can allow inconsistent data in your tables. This script is meant for use in testing and development environments only. It was designed as part of a truncate and import process to add additional data to the testing or development environment.
REM User must have DBA role
set def on ver off
spool enable_disable_fk.log
declare
begin
dbms_output.put_line(l_str_sql_ddl);
if cur_fk%rowcount = 0 then FEEL FREE TO COPY AND USE THE ABOVE CODE FOR DISABLING CONSTRAINTS, BUT REMEMBER: USE AT OWN RISK...
Return from Disabling constraints to Oracle Database constraints
|
![]() Database Design FORUM
What visitors say...
"I just stumbled across your site looking for some normalization theory and I have to say it is fantastic.
Read more
Testimonials
I have been in the database field for 10+ years and I have never before come across such a useful site. Thank you for taking the time to put this site together." Mike, USA Free eBookSubscribe to my newsletter and get my ebook on Entity Relationship Modeling Principles as a free gift:![]() WorkshopOn rare occasions, I may perform a Database Design Workshop . Unfortunately, I am currently unable to, but maybe later...Influence meInfluence the content on this site: I want to know what database information you need the most: Participate in my Database Design Content investigation. I would appreciate it if you took the time... |
|
|
Theory & Practice
Worst DB Designs Database eBooks DB Normalization Analysis Phase Database Keys Software Tools DB Glossary Appl.Architecture Oracle DBA MySQL DBA SQL Server DBA Install Oracle Install SQL Server Proj.Management Oracle Constraint Programming Tips Bookstore Internet biz. Database Normalization eBook:![]() |
||
|
Copyright © 2004-2008 www.databasedesign-resource.com / Alf A. Pedersen
All rights reserved. All information contained on this website is for informational purposes only. *Disclaimer: www.databasedesign-resource.com does not warrant any company, product, service or any content contained herein. Return to top
The name Oracle is a trademark of Oracle Corporation.
|
||