问题
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