Constraints information in the database catalog in DB2
Table 1. Constraints information in the database catalog
Catalog view | View column | Description | Query example |
---|---|---|---|
SYSCAT.CHECKS | Contains a row for each table check constraint | db2 select constname, tabname, text from syscat.checks | |
SYSCAT.COLCHECKS | Contains a row for each column that is referenced by a table check constraint | db2 select constname, tabname, colname, usage from syscat.colchecks | |
SYSCAT.COLUMNS | NULLS | Indicates whether a column is nullable (Y) or not nullable (N) | db2 select tabname, colname, nulls from syscat.columns where tabschema = 'DELSVT' and nulls = 'N' |
SYSCAT.CONSTDEP | Contains a row for each dependency of a constraint on some other object | db2 select constname, tabname, btype, bname from syscat.constdep | |
SYSCAT.INDEXES | Contains a row for each index. | db2 select tabname, uniquerule, made_unique, system_required from syscat.indexes where tabschema = 'DELSVT' | |
SYSCAT.KEYCOLUSE | Contains a row for each column that participates in a key defined by a unique, primary key, or foreign key constraint | db2 select constname, tabname, colname, colseq from syscat.keycoluse | |
SYSCAT.REFERENCES | Contains a row for each referential constraint | db2 select constname, tabname, refkeyname, reftabname, colcount, deleterule, updaterule from syscat.references | |
SYSCAT.TABCONST | Contains a row for each unique (U), primary key (P), foreign key (F), or table check (K) constraint | db2 select constname, tabname, type from syscat.tabconst | |
SYSCAT.TABLES | PARENTS | Number of parent tables of this table (the number of referential constraints in which this table is a dependent) | db2 "select tabname, parents from syscat.tables where parents > 0" |
SYSCAT.TABLES | CHILDREN | Number of dependent tables of this table (the number of referential constraints in which this table is a parent) | db2 "select tabname, children from syscat.tables where children > 0" |
SYSCAT.TABLES | SELFREFS | Number of self-referencing referential constraints for this table (the number of referential constraints in which this table is both a parent and a dependent) | db2 "select tabname, selfrefs from syscat.tables where selfrefs > 0" |
SYSCAT.TABLES | KEYUNIQUE | Number of unique constraints (other than primary key) defined on this table | db2 "select tabname, keyunique from syscat.tables where keyunique > 0" |
SYSCAT.TABLES | CHECKCOUNT | Number of check constraints defined on this table | db2 "select tabname, checkcount from syscat.tables where checkcount > 0" |
Comments
Post a Comment