IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Enforcing Foreign Key


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Apr 17, 2013 9:39 pm
Reply with quote

Hi,

I created a foreign key with "NOT ENFORCED" option.

Code:
ALTER TABLE BHATAB01                                   
        ADD CONSTRAINT BHAC1 FOREIGN KEY           
            (C1
            )                                         
        REFERENCES BHATS002
            (COL1
            )                                         
        ON DELETE RESTRICT                           
        NOT ENFORCED;   


Now when I try running any insert on the child table I notice that the RI constraints are not enforced.

My question is how do I activate the RI constraint now? Can I do It using alter statement? If yes then how?
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Apr 18, 2013 2:06 pm
Reply with quote

Hi..

Any updates on this?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10902
Location: italy

PostPosted: Thu Apr 18, 2013 2:12 pm
Reply with quote

Quote:
Any updates on this?

seem a pretty stupid question... did You see any ?

remember, answering on a forum is ...

on voluntary base
on our time
depends on how interesting is the topic

also remember that soliciting/pestering for answers is just bad forum manners
( on many forums it might get You banned )

what happened also when You looked at the db2 manuals for the syntax of the ALTER command
because You looked ... didn' t You ???
rethoric question
if You had looked You would not have asked icon_cool.gif
Back to top
View user's profile Send private message
Bang_1

New User


Joined: 08 May 2009
Posts: 39
Location: Bangalore

PostPosted: Thu Apr 18, 2013 2:13 pm
Reply with quote

Hi Bharat, can you drop and create the same RI with ENFORCED
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Apr 18, 2013 2:59 pm
Reply with quote

What did your DBA say?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10902
Location: italy

PostPosted: Thu Apr 18, 2013 3:03 pm
Reply with quote

He is the DB2 DBA ! icon_cool.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Apr 18, 2013 3:40 pm
Reply with quote

enrico-sorichetti wrote:
He is the DB2 DBA ! icon_cool.gif


I know Enrico. Thought it was a fun question/response.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10902
Location: italy

PostPosted: Thu Apr 18, 2013 3:43 pm
Reply with quote

looks like the typical case of

when <You> ask Yourself a question...
the reply will certainly be wrong
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Apr 18, 2013 3:52 pm
Reply with quote

yes... i know that we can drop the RI and re-create it with enforced option -- then followed by a check data utility.

I was wondering if there are any other ways to achieve it.. like a simple alter statement?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Apr 18, 2013 3:56 pm
Reply with quote

Did you try that?
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Apr 18, 2013 5:33 pm
Reply with quote

yes i tried it.... dropped and recreate worked for me....
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Foreign character look different in m... COBOL Programming 3
No new posts Unable to create a foreign key DB2 2
No new posts Primery Key / foreign key between Views DB2 1
No new posts Primary-Foreign Key relationship DB2 1
No new posts Can foreign in a table have duplicates DB2 3
Search our Forums:


Back to Top