Filter Queries

Found 1096 queries.

Page 8 of 55
  • All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
  • Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets, it shouldn't be a problem in case of the relatively small amount of data in the system catalog of a database.

#141. CHECK constraint cardinality is zero

INFORMATION_SCHEMA+system catalog base tables

Write correct constraints. Usually the constraint expression should refer to at least one column. A domain constraint expression should refer to the stub VALUE. For instance, the constraint CHECK(1=0) that is associated with a table T would prevent adding any rows to T. The value of the Boolean expression of this constraint is always FALSE.

Problem detection License: MIT (opens in new tab)

#142. CHECK constraints are inconsistent with DEFAULT values

INFORMATION_SCHEMA+system catalog base tables

This query identifies a logical contradiction between data validation rules and default value definitions. It flags CHECK constraints involving two columns where both columns share the same DEFAULT value, yet the constraint enforces a strict inequality (e.g., col1 < col2) or non-equality (col1 <> col2). This configuration is logically flawed because attempting to insert a row using the default values for both columns will result in an immediate constraint violation (as X < X evaluates to false). This renders the default values mutually exclusive and unusable in practice.

Problem detection License: MIT (opens in new tab)

#143. CHECK constraints on columns with Boolean data

INFORMATION_SCHEMA only

Find check constraints that involve columns with the type Boolean.

General License: MIT (opens in new tab)

#144. CHECK constraints on columns with personal names

INFORMATION_SCHEMA only

This query identifies CHECK constraints applied to base or foreign table columns that store personal names. It flags these constraints for review to ensure they are not overly strict. Many regular expressions or character limits fail to account for the complexity of real-world names (such as those containing apostrophes, hyphens, or diacritics), thereby inadvertently preventing the registration of valid legal names.

General License: MIT (opens in new tab)

#145. CHECK constraints on columns with temporal data

INFORMATION_SCHEMA only

If your table contains columns with temporal data, then it will be appropriate to restrict the range of possible values in these columns because some of the values that belong to the type might not be appropriate (for instance, imagine a client who was born in 1100-12-03 or a contract that was registered in 3890-12-12- 12:45). If your table contains multiple columns with temporal data that denote events, then the rule about the order of the events must be enforced, if possible.

General License: MIT (opens in new tab)

#146. CHECK constraints on TIMESTAMP and DATE columns that explicitly specify a time zone

INFORMATION_SCHEMA only

This query identifies semantic anomalies in CHECK constraints applied to columns defined as DATE or TIMESTAMP (without time zone). It flags constraints that incorporate time zone conversion logic (e.g., using AT TIME ZONE). Since these data types store "naive" values devoid of time zone offsets, attempting to apply time zone logic makes the constraint's outcome dependent on the current session or server configuration. This non-deterministic behavior is a design flaw, as data validity should be intrinsic and immutable, not dependent on the environment.

Problem detection License: MIT (opens in new tab)

#147. CHECK constraints on TIMESTAMPTZ and TSTZRANGE columns that do not explicitly specify a time zone

INFORMATION_SCHEMA only

This query identifies CHECK constraints on TIMESTAMPTZ and TSTZRANGE columns that use timestamp literals with fixed UTC offsets instead of named time zones. This practice is flagged as a design flaw because fixed offsets do not account for Daylight Saving Time (DST), leading to constraints on both single timestamps and range boundaries that are unable to correctly represent a local time zone's rules throughout the entire year.

Problem detection License: MIT (opens in new tab)

#148. CHECK constraints that perhaps do not consider 'infinity' and '-infinity' special values

INFORMATION_SCHEMA+system catalog base tables

Find check constraints of base tables that cover exactly one column where the default value of the column is special value 'infinity' or '-infinity'. Find only such constraints that probably check a range of permitted values but do not consider that one of the values might be 'infinity' or '-infinity'. Such special values belong to the types DATE, TIMESTAMP, NUMERIC, REAL, and DOUBLE PRECISION.

Problem detection License: MIT (opens in new tab)

#149. CHECK constraints that perhaps incorrectly consider 'infinity' and '-infinity' special values

INFORMATION_SCHEMA+system catalog base tables

Such special values belong to the types DATE, TIMESTAMP, NUMERIC, REAL, and DOUBLE PRECISION. No value can be bigger than infinity or smaller than -infinity. If the check constraint cheks that a value must be bigger than -infinity or smaller than infinity, then it does not restrict (almost) anything.

Problem detection License: MIT (opens in new tab)

#150. CHECK constraints that use non-deterministic functions

INFORMATION_SCHEMA only

Discover incorrect usage of non-deterministic functions in CHECK constraints. Find base table columns and foreign table columns that have a CHECK constraint that refers to a non-deterministic function that returns current date/time/timestamp.

General License: MIT (opens in new tab)

#151. CHECK constraints with a regular expression permitting whitespace-only or digitless strings

INFORMATION_SCHEMA only

This query identifies table and domain CHECK constraints that use a positive regular expression operator (~ or ~*) whose pattern unintentionally permits strings consisting solely of whitespace characters (or an optional prefix symbol such as + followed only by spaces).

A common regular expression pitfall occurs when a developer includes a space character inside a repeated character class spanning the entire pattern—for example, validating a phone number with CHECK (phone ~ '^\+?[0-9 ]{7,}$') or a name with CHECK (name ~ '^[a-zA-Z ]+$'). Because the character class matches spaces on equal footing with digits or letters and no mandatory digit or letter is required outside the class, strings such as seven spaces (' ') or a plus sign followed by six spaces ('+ ') satisfy the constraint without containing a single digit or letter.

Problem detection License: MIT (opens in new tab)

#152. CHECK constraints with the cardinality bigger than one

system catalog base tables only

Find multicolumn CHECK constraints. Such constraints must be associated directly with a base table, i.e., these cannot be associated with a domain. Enforce as much data integrity as possible at the database level and prefer declarative constraints to a trigger.

General License: MIT (opens in new tab)

#153. CHECK constraints with the cardinality bigger than one that involve the same set of columns

system catalog base tables only

CHECK constraints with the cardinality bigger than one that involve the same set of columns. Make sure that there is no duplication.

General License: MIT (opens in new tab)

#154. CHECK constraint with pattern matching on non-textual columns

INFORMATION_SCHEMA+system catalog base tables

This query identifies a semantic mismatch between data types and constraint logic. It targets base and foreign table columns that are defined with non-textual data types (e.g., INTEGER, DATE, BOOLEAN) but are subject to single-column CHECK constraints utilizing string pattern matching operators (LIKE, SIMILAR TO, or regular expressions). This practice forces implicit casting to text, which is computationally inefficient and indicates a design flaw. It suggests that either the column should utilize a textual data type, or the constraint should be rewritten using operators appropriate for the actual data type (e.g., numeric ranges instead of regex).

Problem detection License: MIT (opens in new tab)

#155. Checking the text maximum length with CHECK

system catalog base tables only

This query identifies all base table columns that enforce a maximum value length through the use of a CHECK constraint. It specifically searches for constraint definitions that contain length-calculating functions (such as length(), char_length(), or similar patterns) to provide a comprehensive list of all columns where data length is explicitly managed by a business rule at the database level.

General License: MIT (opens in new tab)

#156. CHECKs are associated with a column instead of the domain of the column

INFORMATION_SCHEMA+system catalog base tables

Find simple check constraints (involve one column) that are associated with a base table column instead of the domain of the column. Common checks of data in columns that share the same domain should be described at the level of domain not at the level of columns.

Problem detection License: MIT (opens in new tab)

#157. Classifier tables without a name column

INFORMATION_SCHEMA+system catalog base tables

This query identifies classifier (reference data) tables that do not contain a name column. Since the primary purpose of a reference table is to provide human-readable labels for standardized codes, lacking a name column often indicates an incomplete database design.

Problem detection License: MIT (opens in new tab)

#158. Column name contains the table name

INFORMATION_SCHEMA+system catalog base tables

Find columns that have the same name as the table. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent.

General License: MIT (opens in new tab)

#159. Column name is the same as the table name

INFORMATION_SCHEMA+system catalog base tables

Find columns that have the same name as the table. The names may have different uppercase/lowercase characters. Sometimes columns with such names are used as the key columns. Make sure that the naming style is consistent.

General License: MIT (opens in new tab)

#160. Column names that make joining more difficult (foreign key column name contains the table name)

system catalog base tables only

This query identifies foreign key columns where the identifier diverges from the referenced candidate key solely due to the redundant inclusion of the referencing table's name (as a prefix or suffix). Such naming redundancy precludes the use of the simplified SQL USING syntax in join operations, forcing the use of the more verbose ON clause. Harmonizing these column names (i.e., making the foreign key name identical to the referenced column name) enables more concise query formulation and improves schema readability.

Problem detection License: MIT (opens in new tab)
# Name(sorted ascending, activate to sort descending) Goal(activate to sort ascending) Type(activate to sort ascending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
141 CHECK constraint cardinality is zero Write correct constraints. Usually the constraint expression should refer to at least one column. A domain constraint expression should refer to the stub VALUE. For instance, the constraint CHECK(1=0) that is associated with a table T would prevent adding any rows to T. The value of the Boolean expression of this constraint is always FALSE. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
142 CHECK constraints are inconsistent with DEFAULT values This query identifies a logical contradiction between data validation rules and default value definitions. It flags CHECK constraints involving two columns where both columns share the same DEFAULT value, yet the constraint enforces a strict inequality (e.g., col1 < col2) or non-equality (col1 <> col2). This configuration is logically flawed because attempting to insert a row using the default values for both columns will result in an immediate constraint violation (as X < X evaluates to false). This renders the default values mutually exclusive and unusable in practice. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
143 CHECK constraints on columns with Boolean data Find check constraints that involve columns with the type Boolean. General INFORMATION_SCHEMA only MIT (opens in new tab) View
144 CHECK constraints on columns with personal names This query identifies CHECK constraints applied to base or foreign table columns that store personal names. It flags these constraints for review to ensure they are not overly strict. Many regular expressions or character limits fail to account for the complexity of real-world names (such as those containing apostrophes, hyphens, or diacritics), thereby inadvertently preventing the registration of valid legal names. General INFORMATION_SCHEMA only MIT (opens in new tab) View
145 CHECK constraints on columns with temporal data If your table contains columns with temporal data, then it will be appropriate to restrict the range of possible values in these columns because some of the values that belong to the type might not be appropriate (for instance, imagine a client who was born in 1100-12-03 or a contract that was registered in 3890-12-12- 12:45). If your table contains multiple columns with temporal data that denote events, then the rule about the order of the events must be enforced, if possible. General INFORMATION_SCHEMA only MIT (opens in new tab) View
146 CHECK constraints on TIMESTAMP and DATE columns that explicitly specify a time zone This query identifies semantic anomalies in CHECK constraints applied to columns defined as DATE or TIMESTAMP (without time zone). It flags constraints that incorporate time zone conversion logic (e.g., using AT TIME ZONE). Since these data types store "naive" values devoid of time zone offsets, attempting to apply time zone logic makes the constraint's outcome dependent on the current session or server configuration. This non-deterministic behavior is a design flaw, as data validity should be intrinsic and immutable, not dependent on the environment. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
147 CHECK constraints on TIMESTAMPTZ and TSTZRANGE columns that do not explicitly specify a time zone This query identifies CHECK constraints on TIMESTAMPTZ and TSTZRANGE columns that use timestamp literals with fixed UTC offsets instead of named time zones. This practice is flagged as a design flaw because fixed offsets do not account for Daylight Saving Time (DST), leading to constraints on both single timestamps and range boundaries that are unable to correctly represent a local time zone's rules throughout the entire year. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
148 CHECK constraints that perhaps do not consider 'infinity' and '-infinity' special values Find check constraints of base tables that cover exactly one column where the default value of the column is special value 'infinity' or '-infinity'. Find only such constraints that probably check a range of permitted values but do not consider that one of the values might be 'infinity' or '-infinity'. Such special values belong to the types DATE, TIMESTAMP, NUMERIC, REAL, and DOUBLE PRECISION. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
149 CHECK constraints that perhaps incorrectly consider 'infinity' and '-infinity' special values Such special values belong to the types DATE, TIMESTAMP, NUMERIC, REAL, and DOUBLE PRECISION. No value can be bigger than infinity or smaller than -infinity. If the check constraint cheks that a value must be bigger than -infinity or smaller than infinity, then it does not restrict (almost) anything. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
150 CHECK constraints that use non-deterministic functions Discover incorrect usage of non-deterministic functions in CHECK constraints. Find base table columns and foreign table columns that have a CHECK constraint that refers to a non-deterministic function that returns current date/time/timestamp. General INFORMATION_SCHEMA only MIT (opens in new tab) View
151 CHECK constraints with a regular expression permitting whitespace-only or digitless strings This query identifies table and domain CHECK constraints that use a positive regular expression operator (~ or ~*) whose pattern unintentionally permits strings consisting solely of whitespace characters (or an optional prefix symbol such as + followed only by spaces).

A common regular expression pitfall occurs when a developer includes a space character inside a repeated character class spanning the entire pattern—for example, validating a phone number with CHECK (phone ~ '^\+?[0-9 ]{7,}$') or a name with CHECK (name ~ '^[a-zA-Z ]+$'). Because the character class matches spaces on equal footing with digits or letters and no mandatory digit or letter is required outside the class, strings such as seven spaces (' ') or a plus sign followed by six spaces ('+ ') satisfy the constraint without containing a single digit or letter.
Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
152 CHECK constraints with the cardinality bigger than one Find multicolumn CHECK constraints. Such constraints must be associated directly with a base table, i.e., these cannot be associated with a domain. Enforce as much data integrity as possible at the database level and prefer declarative constraints to a trigger. General system catalog base tables only MIT (opens in new tab) View
153 CHECK constraints with the cardinality bigger than one that involve the same set of columns CHECK constraints with the cardinality bigger than one that involve the same set of columns. Make sure that there is no duplication. General system catalog base tables only MIT (opens in new tab) View
154 CHECK constraint with pattern matching on non-textual columns This query identifies a semantic mismatch between data types and constraint logic. It targets base and foreign table columns that are defined with non-textual data types (e.g., INTEGER, DATE, BOOLEAN) but are subject to single-column CHECK constraints utilizing string pattern matching operators (LIKE, SIMILAR TO, or regular expressions). This practice forces implicit casting to text, which is computationally inefficient and indicates a design flaw. It suggests that either the column should utilize a textual data type, or the constraint should be rewritten using operators appropriate for the actual data type (e.g., numeric ranges instead of regex). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
155 Checking the text maximum length with CHECK This query identifies all base table columns that enforce a maximum value length through the use of a CHECK constraint. It specifically searches for constraint definitions that contain length-calculating functions (such as length(), char_length(), or similar patterns) to provide a comprehensive list of all columns where data length is explicitly managed by a business rule at the database level. General system catalog base tables only MIT (opens in new tab) View
156 CHECKs are associated with a column instead of the domain of the column Find simple check constraints (involve one column) that are associated with a base table column instead of the domain of the column. Common checks of data in columns that share the same domain should be described at the level of domain not at the level of columns. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
157 Classifier tables without a name column This query identifies classifier (reference data) tables that do not contain a name column. Since the primary purpose of a reference table is to provide human-readable labels for standardized codes, lacking a name column often indicates an incomplete database design. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
158 Column name contains the table name Find columns that have the same name as the table. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
159 Column name is the same as the table name Find columns that have the same name as the table. The names may have different uppercase/lowercase characters. Sometimes columns with such names are used as the key columns. Make sure that the naming style is consistent. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
160 Column names that make joining more difficult (foreign key column name contains the table name) This query identifies foreign key columns where the identifier diverges from the referenced candidate key solely due to the redundant inclusion of the referencing table's name (as a prefix or suffix). Such naming redundancy precludes the use of the simplified SQL USING syntax in join operations, forcing the use of the more verbose ON clause. Harmonizing these column names (i.e., making the foreign key name identical to the referenced column name) enables more concise query formulation and improves schema readability. Problem detection system catalog base tables only MIT (opens in new tab) View