Filter Queries
- 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.
#181. Columns with array or user-defined type
system catalog base tables onlyThis query identifies columns defined with complex data types, specifically Arrays or User-Defined Types (UDTs). While PostgreSQL supports these advanced features, their indiscriminate use often signals an over-engineered schema. The query serves as a prompt to audit these columns and verify that the complex type is strictly necessary for performance or domain logic, and that a standard relational structure (e.g., scalar types or a child table) would not be a more appropriate and flexible design choice.
#182. Columns with BOOLEAN type that do have a good name
INFORMATION_SCHEMA+system catalog base tablesThis query identifies and lists all BOOLEAN columns that conform to the established predicate-based naming convention. It returns columns whose names begin with one of the approved semantic prefixes: is_, has_, can_, or on_. The output serves as a report of schema components that correctly adhere to best practices for clarity and self-documentation, turning column names into unambiguous true/false questions (e.g., is_agreement instead of agreed).
#183. Columns with BOOLEAN type that do not have a good name
INFORMATION_SCHEMA+system catalog base tablesThis query audits the naming conventions of BOOLEAN columns, enforcing a predicate-based naming convention that begins with is_, has_, can_, or on_. It specifically discourages the use of simple adjectival or past participle forms as column names. For instance, is_agreement is the preferred form over agreed, and on_kinnitatud is preferred over kinnitatud. This standard ensures the column's name is an unambiguous true/false question, which improves schema self-documentation and the readability of SQL queries.
#184. Columns with BYTEA or OID type
INFORMATION_SCHEMA+system catalog base tablesFind columns with BYTEA or OID type. These columns are potentially meant for storing large objects. Each columns should have the most appropriate data type.
#185. Columns with conflicting nullability rules
INFORMATION_SCHEMA onlyThis query identifies a severe logical contradiction in the database schema. It finds situations where a column is strictly defined as NOT NULL (either directly or inherited via a domain), but is simultaneously subject to a CHECK constraint that explicitly requires the value to be missing (e.g., containing an IS NULL condition). This conflict—whether applied as a single-column or multi-column constraint—creates a logical impossibility, preventing any valid data insertion into the table. The query outputs the schema name, table name, column name, domain name (if applicable), the column's mandatory status, and the definition of the problematic CHECK constraint.
#186. Columns with exact/floating numeric types have textual default values
INFORMATION_SCHEMA onlyThe default value of a column should belong to the type of the column. The system shouldn't conduct unnecessary type casts.
#187. Columns with JSON, JSONB, or XML type
INFORMATION_SCHEMA+system catalog base tablesFind columns with JSON, JSONB, or XML type. Each columns should have the most appropriate data type.
#188. Columns with only one value
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that contain only one value. Perhaps it is an unnecessary column. Having only one value is most likely inadequate for testing.
#189. Columns with tsvector type
INFORMATION_SCHEMA+system catalog base tablesFind columns of base tables and materialized views that have tsvector type.
#190. Comments of columns
system catalog base tables onlyFind all comments of columns of tables.
#191. Comments of derived tables
system catalog base tables onlyFind comments of derived tables (views and materialized views) that are registered in the system catalog witht a COMMENT statement. Find also comments on their associated objects (columns, triggers, rules). Make sure that the comments give relevant, useful, and correct information.
#192. Comments of non-derived tables
system catalog base tables onlyFind comments of non-derived tables (base tables, foreign tables, and partitioned tables) that are registered in the system catalog witht a COMMENT statement. Find also comments on their associated objects (columns, constraints, indexes, triggers, rules). Make sure that the comments give relevant, useful, and correct information.
#193. Comments of routines
INFORMATION_SCHEMA+system catalog base tablesFind comments of user-defined routines (functions or procedures) that are registered in the system catalog witht a COMMENT statement. Make sure that the comments give relevant, useful, and correct information.
#194. Comments of schemas, sequences, types, domains, domain constraints, and event triggers
system catalog base tables onlyFind all the comments that have been added with a COMMENT statement to schemas, sequences, types, domains, and event triggers.
#195. Completely overlapping foreign keys
INFORMATION_SCHEMA+system catalog base tablesFind completely overlapping foreign keys, i.e., the same set of columns of a table is covered by more than one foreign key constraint. These constraints could refer to the same table/key or different tables/keys.
#196. Composite foreign keys
system catalog base tables onlyFind foreign keys that consist of more than one column. Make sure that the order of columns in the composite foreign key corresponds to the order of columns in the composite candidate key in the referenced table.
#197. Composite foreign keys with a mix of mandatory and optional columns
system catalog base tables onlyFind composite foreign keys with a mix of mandatory and optional columns. In case of a composite foreign keys all the columns should either optional or mandatory in order to avoid problems with NULLs.
#198. Composite foreign keys with an incorrect order of columns (ver 1)
system catalog base tables onlyFind composite foreign keys where the order of columns does not correspond to the order of columns in the referenced candidate key. Find composite foreign keys in case of which the foreign key and candidate key consist of columns with the same name but the order of columns in the keys is different. For instance, the query returns information about a foreign key (personal_code, country_code) that refers to the candidate key (country_code, personal_code). In SQL keys are ordered sets of columns. Thus, in case of composite foreign key declarations one has to pay attention that the order of columns in the FOREIGN KEY clause matches the order of columns in the REFERENCES clause.
#199. Composite foreign keys with an incorrect order of columns (ver 2)
system catalog base tables onlyFind composite foreign keys where the order of columns does not correspond to the order of columns in the referenced candidate key. Find composite foreign keys in case of which the foreign key and candidate key are not the same in terms of data types of the columns. For instance, the query returns information about a foreign key that columns have the types (SMALLINT, INTEGER) that refers to the candidate key that columns have the types (INTEGER, SMALLINT). In SQL keys are ordered sets of columns. Thus, in case of composite foreign key declarations one has to pay attention that the order of columns in the FOREIGN KEY clause matches the order of columns in the REFERENCES clause.
#200. Consistency of CHECK constraint name and content
INFORMATION_SCHEMA onlyFind all CHECK constraints that name contains a digit. Make sure that the name and the Boolean expression are consistent.
| # | 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 |
|---|---|---|---|---|---|---|---|
| 181 | Columns with array or user-defined type | This query identifies columns defined with complex data types, specifically Arrays or User-Defined Types (UDTs). While PostgreSQL supports these advanced features, their indiscriminate use often signals an over-engineered schema. The query serves as a prompt to audit these columns and verify that the complex type is strictly necessary for performance or domain logic, and that a standard relational structure (e.g., scalar types or a child table) would not be a more appropriate and flexible design choice. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 182 | Columns with BOOLEAN type that do have a good name | This query identifies and lists all BOOLEAN columns that conform to the established predicate-based naming convention. It returns columns whose names begin with one of the approved semantic prefixes: is_, has_, can_, or on_. The output serves as a report of schema components that correctly adhere to best practices for clarity and self-documentation, turning column names into unambiguous true/false questions (e.g., is_agreement instead of agreed). | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 183 | Columns with BOOLEAN type that do not have a good name | This query audits the naming conventions of BOOLEAN columns, enforcing a predicate-based naming convention that begins with is_, has_, can_, or on_. It specifically discourages the use of simple adjectival or past participle forms as column names. For instance, is_agreement is the preferred form over agreed, and on_kinnitatud is preferred over kinnitatud. This standard ensures the column's name is an unambiguous true/false question, which improves schema self-documentation and the readability of SQL queries. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 184 | Columns with BYTEA or OID type | Find columns with BYTEA or OID type. These columns are potentially meant for storing large objects. Each columns should have the most appropriate data type. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 185 | Columns with conflicting nullability rules | This query identifies a severe logical contradiction in the database schema. It finds situations where a column is strictly defined as NOT NULL (either directly or inherited via a domain), but is simultaneously subject to a CHECK constraint that explicitly requires the value to be missing (e.g., containing an IS NULL condition). This conflict—whether applied as a single-column or multi-column constraint—creates a logical impossibility, preventing any valid data insertion into the table. The query outputs the schema name, table name, column name, domain name (if applicable), the column's mandatory status, and the definition of the problematic CHECK constraint. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 186 | Columns with exact/floating numeric types have textual default values | The default value of a column should belong to the type of the column. The system shouldn't conduct unnecessary type casts. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 187 | Columns with JSON, JSONB, or XML type | Find columns with JSON, JSONB, or XML type. Each columns should have the most appropriate data type. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 188 | Columns with only one value | Find base table columns that contain only one value. Perhaps it is an unnecessary column. Having only one value is most likely inadequate for testing. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 189 | Columns with tsvector type | Find columns of base tables and materialized views that have tsvector type. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 190 | Comments of columns | Find all comments of columns of tables. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 191 | Comments of derived tables | Find comments of derived tables (views and materialized views) that are registered in the system catalog witht a COMMENT statement. Find also comments on their associated objects (columns, triggers, rules). Make sure that the comments give relevant, useful, and correct information. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 192 | Comments of non-derived tables | Find comments of non-derived tables (base tables, foreign tables, and partitioned tables) that are registered in the system catalog witht a COMMENT statement. Find also comments on their associated objects (columns, constraints, indexes, triggers, rules). Make sure that the comments give relevant, useful, and correct information. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 193 | Comments of routines | Find comments of user-defined routines (functions or procedures) that are registered in the system catalog witht a COMMENT statement. Make sure that the comments give relevant, useful, and correct information. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 194 | Comments of schemas, sequences, types, domains, domain constraints, and event triggers | Find all the comments that have been added with a COMMENT statement to schemas, sequences, types, domains, and event triggers. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 195 | Completely overlapping foreign keys | Find completely overlapping foreign keys, i.e., the same set of columns of a table is covered by more than one foreign key constraint. These constraints could refer to the same table/key or different tables/keys. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 196 | Composite foreign keys | Find foreign keys that consist of more than one column. Make sure that the order of columns in the composite foreign key corresponds to the order of columns in the composite candidate key in the referenced table. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 197 | Composite foreign keys with a mix of mandatory and optional columns | Find composite foreign keys with a mix of mandatory and optional columns. In case of a composite foreign keys all the columns should either optional or mandatory in order to avoid problems with NULLs. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 198 | Composite foreign keys with an incorrect order of columns (ver 1) | Find composite foreign keys where the order of columns does not correspond to the order of columns in the referenced candidate key. Find composite foreign keys in case of which the foreign key and candidate key consist of columns with the same name but the order of columns in the keys is different. For instance, the query returns information about a foreign key (personal_code, country_code) that refers to the candidate key (country_code, personal_code). In SQL keys are ordered sets of columns. Thus, in case of composite foreign key declarations one has to pay attention that the order of columns in the FOREIGN KEY clause matches the order of columns in the REFERENCES clause. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 199 | Composite foreign keys with an incorrect order of columns (ver 2) | Find composite foreign keys where the order of columns does not correspond to the order of columns in the referenced candidate key. Find composite foreign keys in case of which the foreign key and candidate key are not the same in terms of data types of the columns. For instance, the query returns information about a foreign key that columns have the types (SMALLINT, INTEGER) that refers to the candidate key that columns have the types (INTEGER, SMALLINT). In SQL keys are ordered sets of columns. Thus, in case of composite foreign key declarations one has to pay attention that the order of columns in the FOREIGN KEY clause matches the order of columns in the REFERENCES clause. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 200 | Consistency of CHECK constraint name and content | Find all CHECK constraints that name contains a digit. Make sure that the name and the Boolean expression are consistent. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View |