-------------------------------------------
syscat.tabconst -- to find out all FOREIGN KEY & PRIMARY KEY constraints
of a schema
syscat.references -- TO SEE fk - pk relations
syscat.keyclouse -- to see columns of a constraint
syscat.checks -- for all check constraints of a schema
syscat.indexes -- for unique / non unique indexes.
oRACLE FOREIGN KEY FINDING:
In Oracle 9i, you can find out references table and constraints.
select owner,constraint_name,constraint_type,table_name,r_owner,
r_constraint_name
from all_constraints
where constraint_type='R'
and r_constraint_name
in (select constraint_name
from all_constraints
where constraint_type in ('P','U')
and table_name='APC_WORKSPACES');
iN db2 FORIEGN KEY FINDING:
select reftabname from syscat.references where tabname = 'table1'
Different ways you can do this :
1)
select substr(tabname,1,20) table_name,substr(constname,1,20) fk_name,substr(REFTABNAME,1,12) parent_table,substr(refkeyname,1,20) pk_orig_table,fk_colnames from syscat.references where tabname = 'TABLE_NAME'
2)
Use the command :
db2look -d
Look for 'DDL Statements for foreign keys on Table table_name in the output.
3)
Alternatively, If you have access to control center, right click on the table and select 'generate ddl'.