|
A consulta abaixo lista as restrições de verificação da tabela.
Query below lists table check constraints.
Consulta - Query
SELECT CON.TABSCHEMA CONCAT '.' CONCAT CON.TABNAME AS TABLE
, COL.COLNAME AS COLUMN_NAME
, CON.TEXT AS DEFINITION
, CASE TAB.ENFORCED
WHEN 'N' THEN 'DISABLED'
WHEN 'Y' THEN 'ACTIVE'
END AS STATUS
, CON.CONSTNAME AS CONSTRAINT_NAME
FROM SYSCAT.CHECKS CON
JOIN SYSCAT.COLCHECKS COL ON COL.CONSTNAME = CON.CONSTNAME
AND COL.TABSCHEMA = CON.TABSCHEMA
AND COL.TABNAME = CON.TABNAME
JOIN SYSCAT.TABCONST TAB ON TAB.CONSTNAME = CON.CONSTNAME
AND TAB.TABSCHEMA = CON.TABSCHEMA
AND TAB.TABNAME = CON.TABNAME
WHERE CON.TABSCHEMA NOT LIKE 'SYS%'
ORDER BY CON.TABSCHEMA CONCAT '.' CONCAT CON.TABNAME
, COL.COLNAME
|
Colunas
- tabela - esquema e nome da tabela
- column_name - nome da coluna
- definição - expressão SQL que define esta restrição de verificação
- status - status de restrição:
- 'ativo' se a restrição estiver ativa,
- 'desativado' para restrições desativadas
- constraint_name - nome da restrição no banco de dados
Linhas
- Uma linha representa uma restrição de verificação ou coluna.
Se a restrição de verificação consistir em várias colunas (restrições de verificação em nível de tabela), cada coluna aparecerá separadamente
- Escopo das linhas: a consulta retorna todas as restrições de verificação no banco de dados
- Ordenado por esquema e nome da tabela, nome da coluna
|
Columns
- table - schema and table name
- column_name - name of the column
- definition - SQL expression that defines this check constraint
- status - constraint status:
- 'active' if constraint is active,
- 'disabled' for disabled constraints
- constraint_name - name of the constraint in the database
Rows
- One row represents one check constraint or column.
If check constraint consists of multiple columns (table-level check constraints), each column appears separately
- Scope of rows: query returns all check constraints in the database
- Ordered by table schema and name, column name
|
Resultado - Sample results

Copyright © Dataedo.
|