Answers:
免责声明:我不知道DB2。
我只是用“ db2表定义”对它们进行了搜索。
SELECT *
FROM SYSIBM.SYSTABLES TAB,SYSIBM.SYSCOLUMNS COL
WHERE TAB.CREATOR = COL.TBCREATOR
AND TAB.CREATOR = 'xxxx'
AND TAB.NAME = 'xxxxxxxxxxxxx'
AND TAB.NAME = COL.TBNAME
AND TAB.TYPE = 'V' ( OR 'T' )
ORDER BY 1,2;
SELECT * FROM syscat.tabconst WHERE type = 'P';
您可以执行db2look
,将为您提供该表的ddls。
db2look -d db_name -e -x -z schema_name -t table_name
这可能是最简单的选择,因为匹配索引支持主键:
select COLNAMES from SYSIBM.SYSINDEXES where tbname = 'TABLE' and uniquerule = 'P';
您还可以查询列目录表:
select NAME from SYSIBM.SYSCOLUMNS where tbname = 'TABLE' and keyseq > 0 order by keyseq;