Find domain CHECK constraints that have a too generic name - for instance, the name contains word "data" ) or the name is an abbreviation of the constraint type name (for instance, "chk" or "chk1").
Type
Problem detection (Each row in the result could represent a flaw in the design)
SELECT
domain_schema,
domain_name,
constraint_name AS suspected_constraint_name
FROM INFORMATION_SCHEMA.domain_constraints
WHERE domain_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
AND ((constraint_name~*'(andmed|_data|info|veerg|column|kitsendus|piirang|constraint|restriction)'
AND constraint_name!~*'database')
OR constraint_name~*'^(_){0,1}(ck|chk)(_|[[:digit:]])*$')
ORDER BY domain_schema, domain_name, constraint_name;
Collections
This query belongs to the following collections:
Name
Description
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
Categories
This query is classified under the following categories:
Name
Description
CHECK constraints
Queries of this category provide information about CHECK constraints.
Domains
Queries of this category provide information about reusable specifications of column properties.
Naming
Queries of this category provide information about the style of naming.