Derby - restrictions

On the Derby server, how can you use the information in the schema system tables to create a select statement to get the constraint names for each table?

+5
source share
2 answers

Relevant Guide - Derby Reference Guide . There are many versions: 10.13 were current in April 2017, but in May 2009 they amounted to 10.3%.

Original answer

SELECT c.constraintname, t.tablename
    FROM sysconstraints c, systables t
    WHERE c.tableid = t.tableid;

Derby , sys. (10.13 kiwicomb123 comment), JOIN :

SELECT c.constraintname, t.tablename
  FROM sys.sysconstraints c
  JOIN sys.systables t
    ON c.tableid = t.tableid;

- , c.type, .

+6
SELECT sc.schemaname, co.constraintname, t.tablename, cg.descriptor, t2.tablename, cg2.descriptor, f.deleterule, f.updaterule
FROM sys.sysconstraints co
JOIN sys.sysschemas sc ON co.schemaid = sc.schemaid
JOIN sys.systables t ON co.tableid = t.tableid
JOIN sys.sysforeignkeys f ON co.constraintid = f.constraintid
JOIN sys.sysconglomerates cg ON f.conglomerateid = cg.conglomerateid
JOIN sys.sysconstraints co2 ON f.keyconstraintid = co2.constraintid
JOIN sys.systables t2 ON co2.tableid = t2.tableid
JOIN sys.syskeys k ON co2.constraintid = k.constraintid
JOIN sys.sysconglomerates cg2 ON k.conglomerateid = cg2.conglomerateid
WHERE co.type = 'F' 
    and sc.schemaname = current schema    

,

(2,1)

syscolumns .

- , . .

+2

All Articles