Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Deferred constraints in Oracle (Read 3369 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Deferred constraints in Oracle
07.10.08 at 15:55:06
 
Deferred constraints in Oracle
 
Constraints can be checked at commit time in Oracle. This may be a handy when making updates involving multiple dependencies.
 
Foreign keys can be created as deferrable:
 
CREATE TABLE tab1 (id  NUMBER(10), tab2_id NUMBER(10));
CREATE TABLE tab2 (id  NUMBER(10));
 
ALTER TABLE tab2 ADD PRIMARY KEY (id);
 
ALTER TABLE tab1 ADD CONSTRAINT fk_tab1_tab2
  FOREIGN KEY (tab2_id)
  REFERENCES tab2 (id)
  DEFERRABLE
  INITIALLY IMMEDIATE;
 
Then the session can be set so contraint checking is deferred until a commit is given.
 
ALTER SESSION SET CONSTRAINTS = DEFERRED;
ALTER SESSION SET CONSTRAINTS = IMMEDIATE;
 
Reference:
http://www.oracle-base.com/articles/8i/ConstraintCheckingUpdates.php
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1