Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > IBM DB2 > Re: Question on...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 9029 of 9520
Post > Topic >>

Re: Question on syscat.keycoluse.colseq

by Arun Srinivasan <arunrocks@[EMAIL PROTECTED] > Jun 30, 2008 at 08:05 AM

I just executed the following statements but got the result I needed.
Am confused...
DROP TABLE ARUN.TEST2;
DROP TABLE ARUN.TEST1;
create table arun.test1 (a char(1) not null, b char(1) not null);
create unique index arun.test1_idx2 on arun.test1(b,a) CLUSTER;
create unique index arun.test1_idx1  on arun.test1(a,b) ;

alter table arun.test1 add constraint pk_test1 primary key(a,b);

create table arun.test2(a2 char(1),b2 char(1));
create unique index arun.test2_idx1  on arun.test2(a2,b2) cluster;

alter table arun.test2 ADD constraint fk_test2 foreign key(b2,a2)
references arun.test1;


SELECT
    SUBSTR(R.CONSTNAME, 1, 18) AS KEYNAME,
    SUBSTR(KF.COLNAME, 1, 18)  AS COLNAME,
    SUBSTR(KP.COLNAME, 1, 18)  AS REFCOLNAME
FROM
    SYSCAT.REFERENCES R
    INNER JOIN SYSCAT.KEYCOLUSE KF
        ON R.TABSCHEMA = KF.TABSCHEMA
        AND R.TABNAME = KF.TABNAME
        AND R.CONSTNAME = KF.CONSTNAME
    INNER JOIN SYSCAT.KEYCOLUSE KP
        ON R.REFTABSCHEMA = KP.TABSCHEMA
        AND R.REFTABNAME = KP.TABNAME
        AND R.REFKEYNAME = KP.CONSTNAME
WHERE
	R.TABSCHEMA = 'ARUN' AND
    R.TABNAME = 'TEST2'
    AND KF.COLSEQ = KP.COLSEQ
ORDER BY
    R.TABSCHEMA,
    R.TABNAME,
    R.CONSTNAME,
    KF.COLSEQ
WITH UR;

'FK_TEST2          '	'B2                '	'A                 '
'FK_TEST2          '	'A2                '	'B                 '

This is huge....
 




 6 Posts in Topic:
Question on syscat.keycoluse.colseq
Lennart <Erik.Lennart.  2008-06-27 01:31:57 
Re: Question on syscat.keycoluse.colseq
Lennart <Erik.Lennart.  2008-06-27 02:10:02 
Re: Question on syscat.keycoluse.colseq
"Dave Hughes" &  2008-06-27 08:26:26 
Re: Question on syscat.keycoluse.colseq
Lennart <Erik.Lennart.  2008-06-27 07:18:09 
Re: Question on syscat.keycoluse.colseq
Arun Srinivasan <arunr  2008-06-30 08:05:03 
Re: Question on syscat.keycoluse.colseq
Lennart <Erik.Lennart.  2008-07-17 05:24:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 20:27:01 CST 2008.