如何在Derby中获取主键和唯一约束列 [英] How to Get Primary Key and Unique Constraint Columns in Derby
问题描述
这是怎么做到的? SYSCOLUMNS系统表仅具有表的列。 SYSCHECKS有一个REFERENCEDCOLUMNS对象。有什么办法做到这一点。
How does one do this? The SYSCOLUMNS system table only has columns for tables. SYSCHECKS has a REFERENCEDCOLUMNS object. Is there any way to get this.
我知道JDBC的getPrimaryKeys调用,但这并没有获得唯一的约束列。
I'm aware of the JDBC getPrimaryKeys call, but that doesn't get unique constraint columns.
推荐答案
花了一些时间才找到上述问题;我的问题是上述问题的部分得到解决的后续问题。
It took some digging to find the above question; my question is a partially answered follow-up question to the one above.
对SYSKEYS进行CONSTRAINTID识别时会得到一个CONGLOMERATEID,对SYSCONGLOMERATES进行抽取时会产生一个DESCRIPTOR。 DESCRIPTOR是一个POJO,在baseColumnPositions方法中包含一个int数组。此int数组包含约束中各列的SYSCOLUMNS中的COLUMNNUMBERS。
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.
如果在直接SQL中进行查询,则获取DESCRIPTOR字段将产生一个包含CSV整数列表的字符串必须解析的。对我来说幸运的是,我恰好在Clojure中工作,因此调用baseColumnPositions方法并使用生成的int数组很简单。
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.
这篇关于如何在Derby中获取主键和唯一约束列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!