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.
#441. Patterns of the Boolean expressions of simple CHECK constraints
INFORMATION_SCHEMA+system catalog base tablesFind patterns of the Boolean expressions of simple CHECK constraints (involve only one column). Do not solve the same task in different places differently. The same rule could be implemented with CHECK constraints that have different Boolean expressions. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)
#442. Password should not be open text
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that name refers to the possibility that these are used to register passwords. Find the columns that have a CHECK constraint that seems to determine the minimal permitted length of the values in the column. Passwords in a database table must be hashed and salted. Checking the strength of the password by using a check constraint is in this case impossible and the check constraints that try to do it should be removed from the database.
#443. Password is unique
INFORMATION_SCHEMA+system catalog base tablesFind columns that potentially contains passwords and that participate in a unique constraint or index
#444. Partial or case insensitive unique indexes
INFORMATION_SCHEMA+system catalog base tablesFind partial or case insensitive unique indexes. These implement uniqueness constraints that are impossible to enforce with the help of SQL's regular UNIQUE constraint.
#445. Paramtetes with an array type, XML, JSON, or JSONB type
INFORMATION_SCHEMA+system catalog base tablesFind parameters of user-defined routines that type is an array type, xml, json, or jsonb type. Make sure that the parameter name matches the type (perhaps should be in plural).
#446. Parameter name is the same as the routine name
INFORMATION_SCHEMA+system catalog base tablesFind parameters that have the same name as the routine. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent.
#447. Parameter name is the same as the name of a used column (ver 2)
INFORMATION_SCHEMA+system catalog base tablesIf the name of a routine parameter and the name of a column of a table that is used in the routine are the same, then it makes it more difficult to understand the code.
#448. Parameter name is the same as the name of a used column
INFORMATION_SCHEMA+system catalog base tablesIf the name of a routine parameter and the name of a column of a table that is used in the routine are the same, then it makes it more difficult to understand the code.
#449. Parameter name contains the routine name
INFORMATION_SCHEMA+system catalog base tablesFind parameters that have the same name as the routine. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent.
#450. Pairs of non-key column name and type pairs that have in some base tables a default value and some cases not
INFORMATION_SCHEMA+system catalog base tablesFind non-key base table columns with the same name and type that have in some cases a default value and some cases not. Be consistent. Columns with the same name and type should probably either always have a default value in case of different tables or never have a default value in case of different tables. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)
#451. Pairs of non-key column name and type pairs that have in different base tables a different default value
INFORMATION_SCHEMA+system catalog base tablesFind non-key base table columns with the same name and type that have different default values. Be consistent. Columns with the same name and type shouldn't probably have different default values in case of different tables. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)
#452. Pairs of base tables that have at least two columns with the same names and data types
INFORMATION_SCHEMA onlyWhat are the pairs of base tables that have at least two columns with the same names and data types. The tables might violate the principle of orthogonal design and hence might facilitate uncontrolled data redundancy over different tables.
#453. Oversized classifier code data types
INFORMATION_SCHEMA+system catalog base tablesThis query identifies classifier tables where the code column uses a data type that accommodates unnecessarily large values for reference data. Specifically, it flags code columns defined as integer, bigint, or varchar(n) where n > 10.
#454. Overly strict CHECK constraints on personal names
INFORMATION_SCHEMA onlyThis query identifies potentially overly strict CHECK constraints applied to base or foreign table columns that store personal names. It highlights validation rules that might inadvertently block valid legal names.
#455. Overloading may cause runtime error
INFORMATION_SCHEMA+system catalog base tablesRoutines in the same schema that have the same name and that have parameters with different types or different number of parameters are not considered to be in conflict at the creation time. However, if defaults are provided in the definition of parameters, then these routines might be conflict during runtime.
#456. Overloading
INFORMATION_SCHEMA+system catalog base tablesMake sure that there is genuine overloading instead of duplication or dead code. "In some programming languages, function overloading or method overloading is the ability to create multiple functions of the same name with different implementations." (Wikipedia) In PostgreSQL one can do it automagically by having multiple routines with the same name but different parameters in the same schema.
#457. Overlapping non-function based indexes that have the same leading column but with different operator class
system catalog base tables onlyFind non-function based indexes (both unique and non-unique) that have identical first column but the operator class that is used in case of the first column is different. Include unique indexes that support a constraint (primary key, unique, exclude), i.e., these indexes have been automatically created due to the constraint declaration.
#458. Ordinal position of primary key columns
INFORMATION_SCHEMA+system catalog base tablesThis query retrieves the ordinal positions of primary key columns for all base tables within the database, explicitly including those created via inheritance. It acts as an auditing tool to help database administrators and developers understand column layouts and verify schema design conventions across the entire table hierarchy.
#459. Optional non-foreign columns participating in unique keys
INFORMATION_SCHEMA+system catalog base tablesThis query identifies optional (nullable) base table columns that participate in a UNIQUE constraint or index, but do not participate in a FOREIGN KEY constraint. In database design, tables use candidate keys to uniquely identify rows; one acts as the primary key, while the others serve as alternate keys. To properly enforce a standalone alternate key, all its columns should be mandatory (NOT NULL). Columns involved in foreign keys are excluded from this check, as optional relationships legitimately require nullable foreign keys. The query also exempts constraints that explicitly use the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULL values as equal.
#460. Optional foreign key columns
INFORMATION_SCHEMA onlyFind foreign key columns that do not have the NOT NULL constraint. It is better to limit the use of NULLs and optional columns due to the problems that it causes in interpreting the query results, making queries, and enforcing constraints. In addition, one should check as to whether this kind of design is consistent with the multiplicities in the conceptual data model.
| # | Name(sorted descending, activate to sort ascending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(activate to sort ascending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 441 | Patterns of the Boolean expressions of simple CHECK constraints | Find patterns of the Boolean expressions of simple CHECK constraints (involve only one column). Do not solve the same task in different places differently. The same rule could be implemented with CHECK constraints that have different Boolean expressions. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code) | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 442 | Password should not be open text | Find base table columns that name refers to the possibility that these are used to register passwords. Find the columns that have a CHECK constraint that seems to determine the minimal permitted length of the values in the column. Passwords in a database table must be hashed and salted. Checking the strength of the password by using a check constraint is in this case impossible and the check constraints that try to do it should be removed from the database. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 443 | Password is unique | Find columns that potentially contains passwords and that participate in a unique constraint or index | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 444 | Partial or case insensitive unique indexes | Find partial or case insensitive unique indexes. These implement uniqueness constraints that are impossible to enforce with the help of SQL's regular UNIQUE constraint. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 445 | Paramtetes with an array type, XML, JSON, or JSONB type | Find parameters of user-defined routines that type is an array type, xml, json, or jsonb type. Make sure that the parameter name matches the type (perhaps should be in plural). | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 446 | Parameter name is the same as the routine name | Find parameters that have the same name as the routine. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 447 | Parameter name is the same as the name of a used column (ver 2) | If the name of a routine parameter and the name of a column of a table that is used in the routine are the same, then it makes it more difficult to understand the code. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 448 | Parameter name is the same as the name of a used column | If the name of a routine parameter and the name of a column of a table that is used in the routine are the same, then it makes it more difficult to understand the code. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 449 | Parameter name contains the routine name | Find parameters that have the same name as the routine. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 450 | Pairs of non-key column name and type pairs that have in some base tables a default value and some cases not | Find non-key base table columns with the same name and type that have in some cases a default value and some cases not. Be consistent. Columns with the same name and type should probably either always have a default value in case of different tables or never have a default value in case of different tables. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code) | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 451 | Pairs of non-key column name and type pairs that have in different base tables a different default value | Find non-key base table columns with the same name and type that have different default values. Be consistent. Columns with the same name and type shouldn't probably have different default values in case of different tables. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code) | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 452 | Pairs of base tables that have at least two columns with the same names and data types | What are the pairs of base tables that have at least two columns with the same names and data types. The tables might violate the principle of orthogonal design and hence might facilitate uncontrolled data redundancy over different tables. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 453 | Oversized classifier code data types | This query identifies classifier tables where the code column uses a data type that accommodates unnecessarily large values for reference data. Specifically, it flags code columns defined as integer, bigint, or varchar(n) where n > 10. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 454 | Overly strict CHECK constraints on personal names | This query identifies potentially overly strict CHECK constraints applied to base or foreign table columns that store personal names. It highlights validation rules that might inadvertently block valid legal names. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 455 | Overloading may cause runtime error | Routines in the same schema that have the same name and that have parameters with different types or different number of parameters are not considered to be in conflict at the creation time. However, if defaults are provided in the definition of parameters, then these routines might be conflict during runtime. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 456 | Overloading | Make sure that there is genuine overloading instead of duplication or dead code. "In some programming languages, function overloading or method overloading is the ability to create multiple functions of the same name with different implementations." (Wikipedia) In PostgreSQL one can do it automagically by having multiple routines with the same name but different parameters in the same schema. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 457 | Overlapping non-function based indexes that have the same leading column but with different operator class | Find non-function based indexes (both unique and non-unique) that have identical first column but the operator class that is used in case of the first column is different. Include unique indexes that support a constraint (primary key, unique, exclude), i.e., these indexes have been automatically created due to the constraint declaration. | General | system catalog base tables only | MIT (opens in new tab) | View | |
| 458 | Ordinal position of primary key columns | This query retrieves the ordinal positions of primary key columns for all base tables within the database, explicitly including those created via inheritance. It acts as an auditing tool to help database administrators and developers understand column layouts and verify schema design conventions across the entire table hierarchy. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 459 | Optional non-foreign columns participating in unique keys | This query identifies optional (nullable) base table columns that participate in a UNIQUE constraint or index, but do not participate in a FOREIGN KEY constraint. In database design, tables use candidate keys to uniquely identify rows; one acts as the primary key, while the others serve as alternate keys. To properly enforce a standalone alternate key, all its columns should be mandatory (NOT NULL). Columns involved in foreign keys are excluded from this check, as optional relationships legitimately require nullable foreign keys. The query also exempts constraints that explicitly use the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULL values as equal. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 460 | Optional foreign key columns | Find foreign key columns that do not have the NOT NULL constraint. It is better to limit the use of NULLs and optional columns due to the problems that it causes in interpreting the query results, making queries, and enforcing constraints. In addition, one should check as to whether this kind of design is consistent with the multiplicities in the conceptual data model. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View |