derby system tables for the column of primary key info

无人久伴 提交于 2019-12-11 06:26:41

问题


I'm trying to retrieve the columns for PK from system tables and looking through the documentation I cannot see how I can get that information. SYS.SYSCONSTRAINTS does not contain column information.

I want to know which column belong to for the primary key. I find the tables in sys schema then I can get all the primary key info. The SQL is:

select t.tablename,
conglomeratename backIdxName,
cst.constraintname,
cst.type
from sys.systables   t,
sys.sysconstraints   cst,
sys.sysconglomerates cgl,
sys.syskeys          sk
where isindex = 'TRUE'
and cgl.tableid = t.tableid
and (sk.constraintid = cst.constraintid and cst.type = 'P' and
sk.conglomerateid = cgl.conglomerateid)
and t.tableid = cst.tableid
and t.tabletype = 'T'

all the primary key is query out, but I wanna know the relation between primary key and column. I don't know which the column belong to for the primary key. I find sys.syscolumns table but nothing useful.

anybody know it ?

thanks.

来源:https://stackoverflow.com/questions/20396376/derby-system-tables-for-the-column-of-primary-key-info

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!