Ruben Laguna's blog

Oct 16, 2007 - 1 minute read - apache derby describe java key show sys unique

How to get information on UNIQUE keys on Apache Derby

It’s not easy to get information on derby keys once you created them. I was looking for a command like “SHOW CREATE TABLE ” but no luck. I realized that the answer should lay in SYS tables. After googling a while I found the following bit of wisdom:

select c.constraintname, c.constraintid from sys.systables t, sys.sysconstraints c where t.tablename = ‘FOO’ and t.tableid = c.tableid and c.type = ‘U’;

select g.descriptor
from sys.systables t, sys.sysconstraints c, sys.syskeys k,
sys.sysconglomerates g
where t.tablename = 'FOO'
and t.tableid = c.tableid
and c.type = 'U'
and c.constraintid = k.constraintid
and k.conglomerateid = g.conglomerateid;