If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Referential Integrity rules

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-11-07, 17:00
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Referential Integrity rules

Hello, Have been reading the theory of DB2 Constraints for DB2 9. But I could not find any difference on the 2 update rules which is present namely Restrict and No Action.

Can you pls help me to understand it practically.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 04-11-07, 23:51
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Check the SQL Reference Vol 2 for Create Table.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 04-12-07, 06:16
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
RESTRICT prevents an update if there are dependent records. NO ACTION performs the update and then checks if everything is fine afterwards. So NO ACTION could allow triggers to fire and fix things. Here is another example that fails with RESTRICT but succeeds with NO ACTION:
Code:
CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY );
CREATE TABLE t2 ( b INT, FOREIGN KEY (b) REFERENCES t1 ON UPDATE NO ACTION );
INSERT INTO t1 VALUES (2), (3), (4);
INSERT INTO t2 VALUES (2), (3);
UPDATE t1 SET a = a - 1;
RESTRICT detects dependent rows and bails out. NO ACTION succeeds because all dependent rows in T2 still have a matching row it T1 after the UPDATE.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On