Anyone has access to an 8i machine? If so: the following query seems to give different results on 8i than on 9i. On 9i it gives the proper results, but on 8i it seems to give all the constraints not the FK's.
Could someone with access to 8i run this query? thanks. The Query should list all foreign keys by table, sorted: FK table, FK name, field name . Change the string 'schema' with the schema you run the query on, so for example 'schema' is replaced with 'SCOTT'.
SELECT CCFK.OWNER AS FK_TABLE_SCHEMA,
CCFK.TABLE_NAME AS FK_TABLE_NAME,
CCFK.COLUMN_NAME AS FK_COLUMN,
CCFK.POSITION AS FK_POSITION,
CCPK.OWNER AS PK_TABLE_SCHEMA,
CCPK.TABLE_NAME AS PK_TABLE_NAME,
CCPK.COLUMN_NAME AS PK_COLUMN,
CCPK.POSITION AS PK_POSITION,
C.R_CONSTRAINT_NAME AS FK_NAME
FROM ALL_CONS_COLUMNS CCFK,
ALL_CONS_COLUMNS CCPK,
ALL_CONSTRAINTS C
WHERE CCFK.CONSTRAINT_NAME = C.CONSTRAINT_NAME
AND CCFK.OWNER = C.OWNER
AND C.CONSTRAINT_TYPE='R'
AND C.R_CONSTRAINT_NAME = CCPK.CONSTRAINT_NAME
AND C.R_OWNER = CCPK.OWNER
AND CCFK.OWNER='schema'
ORDER BY CCFK.TABLE_NAME, C.R_CONSTRAINT_NAME, CCFK.COLUMN_NAME, CCFK.POSITION
Update: It doesn't seem to be different on 8i. ..