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.
#161. Column names that make joining more difficult (foreign key column name equals the referenced table name)
system catalog base tables onlyThis query identifies foreign key columns where the identifier is identical to the name of the referenced table. This naming pattern typically results in a mismatch between the foreign key column and the referenced primary key column (e.g., a column named department referencing a table department with a primary key department_id). This mismatch precludes the use of the simplified ANSI SQL USING clause in join operations, necessitating the use of the more verbose ON clause. Harmonizing the column name to match the referenced key enables more concise query formulation.
The Example: A table Employees has a column named Department that links to the Department table (where the ID is department_id). The Problem: Because the column is named Department and not department_id, you cannot use the shortcut syntax: JOIN Department USING (department_id). You are forced to write: JOIN Department ON Employees.Department = Department.department_id.
#162. Column names that make joining tables more difficult
system catalog base tables onlyThis query identifies foreign key columns where the identifier differs from the referenced candidate key identifier. It explicitly excludes self-referencing constraints (recursive relationships), where name divergence is structurally mandatory. The primary objective is to identify opportunities to harmonize column names across the schema. Synchronizing the foreign key name with the referenced column name facilitates the use of the ANSI SQL USING clause in join operations (e.g., JOIN t1 USING (client_id)), which is significantly more concise than the explicit ON predicate required when names differ.
#163. Column names that make joining tables more difficult (quite similar names)
system catalog base tables onlyThis query identifies foreign key columns where the identifier deviates slightly from the referenced candidate key, specifically exhibiting a textual difference (Levenshtein distance) of two to four characters. This range typically captures minor prefixes (e.g., fk_) or suffixes that prevent the use of the concise SQL USING syntax in join operations. The query explicitly excludes self-referencing constraints (recursive relationships), where distinct column names are structurally mandatory. Aligning these names allows for cleaner, more readable query formulation.
#164. Column names that make joining tables more difficult (table names)
system catalog base tables onlyThis query identifies foreign key relationships where the identifier of the referenced column diverges from the foreign key column solely due to the inclusion of the table name. It specifically targets cases where the referenced column name is formed by concatenating the target table name with the target column name (e.g., referenced_col = table_name || '_' || fk_col). This naming redundancy prevents the use of the simplified SQL USING syntax for join operations, necessitating verbose ON clauses. Harmonizing these identifiers by standardizing the naming convention improves schema readability and query conciseness.
#165. Column names that make joining tables more difficult (very similar names)
system catalog base tables onlyThis query identifies foreign key columns where the identifier exhibits a minimal textual deviation (exactly one character) from the referenced candidate key. This specific proximity often indicates a typographical error or a singular/plural inconsistency (e.g., user_id vs users_id). The query explicitly excludes self-referencing constraints, where name divergence is structurally mandatory. Harmonizing these names enables the use of the simplified SQL USING syntax for joins, replacing verbose ON clauses and improving query readability.
#166. Column references in DELETE trigger exceptions
INFORMATION_SCHEMA+system catalog base tablesThis query identifies DELETE trigger routines that raise an exception and explicitly specify a column in the error context (using the COLUMN clause). This is generally a logical mismatch, as a DELETE operation affects an entire row rather than individual columns. Providing a column-specific error context in this scenario often indicates a copy-paste error from an INSERT or UPDATE trigger.
#167. Columns defined in a subtable
INFORMATION_SCHEMA+system catalog base tablesFind columns that have been added to a subtable, i.e., these were not defined in its immediate supertable.
#168. Columns for registration and update times
INFORMATION_SCHEMA onlyFind base table columns that based on the names and data types are meant for registering registration time or update time. Make sure that the columns have the same properties.
#169. Columns of base tables that hold truth values but do not have a default value (Boolean columns)
INFORMATION_SCHEMA onlyFind columns of base tables that have type BOOLEAN but do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. Often it should be possible to select one of these as the default value of a column that has BOOLEAN type.
#170. Columns of base tables that hold truth values but do not have a default value (non-Boolean columns)
INFORMATION_SCHEMA+system catalog base tablesFind non-foreign key columns of base tables that probably (based on the column name) contain values that represent truth values but do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It could be possible to select one of these as the default value in case of the columns.
#171. Columns of base tables that hold truth values but do not restrict the permitted values (non-Boolean columns)
INFORMATION_SCHEMA+system catalog base tablesFind non-foreign key columns of base tables that probably (based on the column name) contain values that represent truth values but do not have a have a check constraint. The constraint should restrict the permitted values with values that represent truth values TRUE and FALSE.
#172. Columns of base tables that hold truth values that do not have a default value although they could have it (Boolean columns)
INFORMATION_SCHEMA onlyFind columns of base tables that have type BOOLEAN. Based on column names these implement a state machine or record agreements. At the same time the columns do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It should be possible to select one of these as the default value of the column.
#173. Columns of base tables that hold truth values that do not have a default value although they could have it (non-Boolean columns)
INFORMATION_SCHEMA+system catalog base tablesFind columns of base tables that do not have type BOOLEAN but are used to record Boolean values. Based on column names these implement a state machine or record agreements. At the same time the columns do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It should be possible to select one of these as the default value of the column.
#174. Columns of base tables with data about postal addresses, file addresses, or web addresses that have an incorrect data type
INFORMATION_SCHEMA onlyFind base table columns that name refers to the possibility that these are used to register file/web addresses. Find the columns where the type refers to the possibility that values in the column are actual files.
#175. Columns of derived tables that name has been given by the system
system catalog base tables onlyFind columns of derived tables (i.e., views and materialized views) where in the creation statement of the table the name of the column has not been specified, i.e., it is generated by the system.
#176. Columns of derived tables that name has been given by the system (2)
system catalog base tables onlyFind columns of derived tables (i.e., views and materialized views) where in the creation statement of the table the name of the column has not been specified, i.e., it is generated by the system.
#177. Columns that have the same name as some domain/type
INFORMATION_SCHEMA+system catalog base tablesUse different names to avoid confusion.
#178. Columns that have the same name as their domain/type
INFORMATION_SCHEMA+system catalog base tablesFind the columns that name is the same as the name of the type of the column or the domain of the column.
#179. Columns with a CHECK constraint permitting only a single constant value
INFORMATION_SCHEMA+system catalog base tablesThis query identifies columns of base tables and foreign tables that have a single-column table or domain CHECK constraint restricting the column to only one fixed value (for example, col = 5, col = 'test', or VALUE = false).
Restricting a column to a single constant value is frequently a schema design flaw or a typo in the constraint definition (for instance, mistakenly using the equality operator = instead of LIKE, ~, IN (...), or a range operator, as in a = 'a%'). Storing an identical constant in every row of a multi-row table also wastes storage and obscures schema intent.
However, such a constraint may be intentional and valid in two specific cases:
- The column belongs to a subtable inherited from a supertable, where the constraint fixes a subtype discriminator or specialized attribute value (the query displays
supertable_schemaandsupertable_nameto help identify these cases). - The constraint is combined with a
PRIMARY KEYorUNIQUEconstraint to enforce a singleton table that can contain at most one row (e.g.,id = 1).
#180. Columns with a range type that require a better name
INFORMATION_SCHEMA onlyThis query identifies columns with a RANGE data type that violate naming conventions. It flags columns whose names do not semantically suggest a range or period, which can create ambiguity and lead to incorrect assumptions when writing queries.
| # | 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 |
|---|---|---|---|---|---|---|---|
| 161 | Column names that make joining more difficult (foreign key column name equals the referenced table name) | This query identifies foreign key columns where the identifier is identical to the name of the referenced table. This naming pattern typically results in a mismatch between the foreign key column and the referenced primary key column (e.g., a column named department referencing a table department with a primary key department_id). This mismatch precludes the use of the simplified ANSI SQL USING clause in join operations, necessitating the use of the more verbose ON clause. Harmonizing the column name to match the referenced key enables more concise query formulation. The Example: A table Employees has a column named Department that links to the Department table (where the ID is department_id). The Problem: Because the column is named Department and not department_id, you cannot use the shortcut syntax: JOIN Department USING (department_id). You are forced to write: JOIN Department ON Employees.Department = Department.department_id. |
Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 162 | Column names that make joining tables more difficult | This query identifies foreign key columns where the identifier differs from the referenced candidate key identifier. It explicitly excludes self-referencing constraints (recursive relationships), where name divergence is structurally mandatory. The primary objective is to identify opportunities to harmonize column names across the schema. Synchronizing the foreign key name with the referenced column name facilitates the use of the ANSI SQL USING clause in join operations (e.g., JOIN t1 USING (client_id)), which is significantly more concise than the explicit ON predicate required when names differ. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 163 | Column names that make joining tables more difficult (quite similar names) | This query identifies foreign key columns where the identifier deviates slightly from the referenced candidate key, specifically exhibiting a textual difference (Levenshtein distance) of two to four characters. This range typically captures minor prefixes (e.g., fk_) or suffixes that prevent the use of the concise SQL USING syntax in join operations. The query explicitly excludes self-referencing constraints (recursive relationships), where distinct column names are structurally mandatory. Aligning these names allows for cleaner, more readable query formulation. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 164 | Column names that make joining tables more difficult (table names) | This query identifies foreign key relationships where the identifier of the referenced column diverges from the foreign key column solely due to the inclusion of the table name. It specifically targets cases where the referenced column name is formed by concatenating the target table name with the target column name (e.g., referenced_col = table_name || '_' || fk_col). This naming redundancy prevents the use of the simplified SQL USING syntax for join operations, necessitating verbose ON clauses. Harmonizing these identifiers by standardizing the naming convention improves schema readability and query conciseness. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 165 | Column names that make joining tables more difficult (very similar names) | This query identifies foreign key columns where the identifier exhibits a minimal textual deviation (exactly one character) from the referenced candidate key. This specific proximity often indicates a typographical error or a singular/plural inconsistency (e.g., user_id vs users_id). The query explicitly excludes self-referencing constraints, where name divergence is structurally mandatory. Harmonizing these names enables the use of the simplified SQL USING syntax for joins, replacing verbose ON clauses and improving query readability. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 166 | Column references in DELETE trigger exceptions | This query identifies DELETE trigger routines that raise an exception and explicitly specify a column in the error context (using the COLUMN clause). This is generally a logical mismatch, as a DELETE operation affects an entire row rather than individual columns. Providing a column-specific error context in this scenario often indicates a copy-paste error from an INSERT or UPDATE trigger. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 167 | Columns defined in a subtable | Find columns that have been added to a subtable, i.e., these were not defined in its immediate supertable. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 168 | Columns for registration and update times | Find base table columns that based on the names and data types are meant for registering registration time or update time. Make sure that the columns have the same properties. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 169 | Columns of base tables that hold truth values but do not have a default value (Boolean columns) | Find columns of base tables that have type BOOLEAN but do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. Often it should be possible to select one of these as the default value of a column that has BOOLEAN type. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 170 | Columns of base tables that hold truth values but do not have a default value (non-Boolean columns) | Find non-foreign key columns of base tables that probably (based on the column name) contain values that represent truth values but do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It could be possible to select one of these as the default value in case of the columns. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 171 | Columns of base tables that hold truth values but do not restrict the permitted values (non-Boolean columns) | Find non-foreign key columns of base tables that probably (based on the column name) contain values that represent truth values but do not have a have a check constraint. The constraint should restrict the permitted values with values that represent truth values TRUE and FALSE. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 172 | Columns of base tables that hold truth values that do not have a default value although they could have it (Boolean columns) | Find columns of base tables that have type BOOLEAN. Based on column names these implement a state machine or record agreements. At the same time the columns do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It should be possible to select one of these as the default value of the column. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 173 | Columns of base tables that hold truth values that do not have a default value although they could have it (non-Boolean columns) | Find columns of base tables that do not have type BOOLEAN but are used to record Boolean values. Based on column names these implement a state machine or record agreements. At the same time the columns do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It should be possible to select one of these as the default value of the column. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 174 | Columns of base tables with data about postal addresses, file addresses, or web addresses that have an incorrect data type | Find base table columns that name refers to the possibility that these are used to register file/web addresses. Find the columns where the type refers to the possibility that values in the column are actual files. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 175 | Columns of derived tables that name has been given by the system | Find columns of derived tables (i.e., views and materialized views) where in the creation statement of the table the name of the column has not been specified, i.e., it is generated by the system. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 176 | Columns of derived tables that name has been given by the system (2) | Find columns of derived tables (i.e., views and materialized views) where in the creation statement of the table the name of the column has not been specified, i.e., it is generated by the system. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 177 | Columns that have the same name as some domain/type | Use different names to avoid confusion. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 178 | Columns that have the same name as their domain/type | Find the columns that name is the same as the name of the type of the column or the domain of the column. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 179 | Columns with a CHECK constraint permitting only a single constant value | This query identifies columns of base tables and foreign tables that have a single-column table or domain CHECK constraint restricting the column to only one fixed value (for example, col = 5, col = 'test', or VALUE = false).Restricting a column to a single constant value is frequently a schema design flaw or a typo in the constraint definition (for instance, mistakenly using the equality operator = instead of LIKE, ~, IN (...), or a range operator, as in a = 'a%'). Storing an identical constant in every row of a multi-row table also wastes storage and obscures schema intent.However, such a constraint may be intentional and valid in two specific cases:
|
General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 180 | Columns with a range type that require a better name | This query identifies columns with a RANGE data type that violate naming conventions. It flags columns whose names do not semantically suggest a range or period, which can create ambiguity and lead to incorrect assumptions when writing queries. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View |