Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Enforcing Foreign Key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Enforcing Foreign Key
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    Post subject:
Reply with quote

Hi..

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Apr 18, 2013 2:12 pm    Post subject: Reply to: Enforcing Foreign Key
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    Post subject:
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: 2422
Location: Netherlands, Amstelveen

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

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Apr 18, 2013 3:03 pm    Post subject: Reply to: Enforcing Foreign Key
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Apr 18, 2013 3:40 pm    Post subject: Re: Reply to: Enforcing Foreign Key
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Apr 18, 2013 3:43 pm    Post subject: Reply to: Enforcing Foreign Key
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    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Apr 18, 2013 3:56 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Unable to create a foreign key princegaurav DB2 2 Tue Nov 06, 2012 6:24 pm
No new posts Primery Key / foreign key between Views bauer DB2 1 Fri Dec 16, 2011 11:56 am
No new posts Primary-Foreign Key relationship ppandey07 DB2 1 Tue Jul 12, 2011 9:46 am
No new posts Can foreign in a table have duplicates sree reddy DB2 3 Mon Aug 17, 2009 9:46 pm
This topic is locked: you cannot edit posts or make replies. Mainframe+Spanish- Foreign Nationalit... SHARLIN RANJANI Mainframe Jobs 0 Fri Dec 05, 2008 7:03 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us