2

如何做到这一点?SYSCOLUMNS 系统表只有表的列。SYSCHECKS 有一个 REFERENCEDCOLUMNS 对象。有没有办法得到这个。

我知道 JDBC getPrimaryKeys 调用,但它没有获得唯一约束列。

4

1 回答 1

3

Derby - constraints

It took some digging to find the above question; my question is a partially answered follow-up question to the one above.

Taking the CONSTRAINTID against SYSKEYS gives a CONGLOMERATEID, which when taken against SYSCONGLOMERATES yields a DESCRIPTOR. The DESCRIPTOR is a POJO that contains an int-array in the baseColumnPositions method. This int-array contains the COLUMNNUMBERS in SYSCOLUMNS of the columns in the constraint.

If querying in straight SQL, getting the DESCRIPTOR field yields a string with a CSV list of ints that have to be parsed. Fortunately for me, I happen to be working in Clojure, so calling the baseColumnPositions method and using the resulting int-array are trivial.

于 2010-02-28T03:01:33.957 回答