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 > Finding referential constraints

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-05, 13:33
mohd mohd is offline
Registered User
 
Join Date: Jul 2003
Posts: 63
Question Finding referential constraints

Hi,

can i get DB2 equivalent of this oracle Query.

this is to get all foreign key constraints which are dependent on table 'ABC'

Select * from user_constraints
where R_constraint_name=( select constraint_name from user_constraints
where constraint_type='P' and table_name='ABC')


And also where can we find a list of all constraints under a schema ?

Thx
__________________
Mohd
Reply With Quote
  #2 (permalink)  
Old 02-17-05, 00:43
jacampbell jacampbell is offline
Registered User
 
Join Date: Jan 2005
Posts: 191
select ... from syscat.references where reftabname = 'ABC'
(don't know enough O to know exactly what you want. You might also need a join onto syscat.keycoluse.

select ... from syscat.colchecks where tabschema = 'AAAA'

James Campbell
Reply With Quote
  #3 (permalink)  
Old 02-17-05, 10:52
mohd mohd is offline
Registered User
 
Join Date: Jul 2003
Posts: 63
Thx James.
Here is the exact SQL i was looking for

select constname , tabschema, tabname,definer, reftabname,fk_colnames,pk_colnames
from syscat.references where tabschema='DB2INST1' and reftabname='ABC'

This will give all the tables with column names dependent on table 'ABC'


Thx
__________________
Mohd
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