Filter Queries

Found 1092 queries.

Page 32 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.

#621. One true lookup table

system catalog base tables only

This query identifies central classifier (reference) tables that store all or most of the system's reference values, along with the dependent tables that reference them.

Problem detection License: MIT (opens in new tab)

#622. Only ID primary key

INFORMATION_SCHEMA+system catalog base tables

Find base base tables have the simple primary key that contains a column with the (case insensitive) name id and an integer type. In addition, the primary key values are generated automatically by the system by using a sequence generator. In addition the base table must not have any unique constraint.

Problem detection License: MIT (opens in new tab)

#623. Only one value permitted in a base table or a foreign table column (based on enumeration types)

INFORMATION_SCHEMA+system catalog base tables

Find columns of base tables or foreign tables in case of which the type of the column permits only one value in the column. The type is an enumeration type that specifies only one value.

Problem detection License: MIT (opens in new tab)

#624. ON UPDATE CASCADE is missing (based on classifier tables)

INFORMATION_SCHEMA+system catalog base tables

This query identifies foreign key constraints referencing classifier tables that lack an ON UPDATE CASCADE clause. Classifier tables hold reference data (e.g., status types, categories). While their rows should not be deleted if they are currently in use, any modifications to their underlying codes should automatically cascade to all dependent tables to maintain data integrity.

Problem detection License: MIT (opens in new tab)

#625. ON UPDATE CASCADE is perhaps missing (based on the compensating actions of other foreign key constraints)

system catalog base tables only

This query detects inconsistencies in the application of ON UPDATE CASCADE for foreign keys referencing the same candidate key. It identifies sets of foreign key constraints where a proper, non-empty subset is configured with ON UPDATE CASCADE. Such a mixed configuration is a functional flaw, as any attempt to update the parent key will be blocked by the non-cascading constraints, rendering the CASCADE action ineffective and preventing the intended data modification. The principle of atomicity requires that for any given key, either all referencing foreign keys have ON UPDATE CASCADE, or none do.

Problem detection License: MIT (opens in new tab)

#626. ON UPDATE CASCADE is probably missing (based on column names)

system catalog base tables only

This query identifies foreign key constraints that are likely missing an ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing a natural key should permit cascading updates. The query uses a naming convention to identify probable natural keys, specifically flagging foreign key columns having the suffix or prefix "code" on the assumption that such values are user-defined and may require modification. The absence of ON UPDATE CASCADE on these keys can lead to referential integrity violations when the parent key is updated.

Problem detection License: MIT (opens in new tab)

#627. ON UPDATE CASCADE is probably missing (based on data types)

INFORMATION_SCHEMA+system catalog base tables

This query identifies foreign key constraints that likely require an ON UPDATE CASCADE action. It operates on a strong heuristic based on data type: the query flags foreign keys where the column type is neither integer nor uuid and the ON UPDATE CASCADE action is absent. This assumes that non-numeric, non-UUID keys are natural keys (e.g., VARCHAR, CHAR) whose values are meaningful and may need to be updated over time. The absence of ON UPDATE CASCADE on these relationships can impede data maintenance and violate referential integrity upon updates.

Problem detection License: MIT (opens in new tab)

#628. ON UPDATE CASCADE is probably missing (based on the properties of the referenced column)

INFORMATION_SCHEMA+system catalog base tables

This query identifies foreign key constraints that are likely missing an ON UPDATE CASCADE action on what is inferred to be a simple, integer-based natural key. It isolates referenced keys that are single integer columns, are not themselves foreign keys, and, crucially, have no associated sequence generator. This combination strongly indicates a manually managed key whose values might change. The absence of ON UPDATE CASCADE on such relationships can lead to significant data maintenance issues if the natural key value ever needs to be updated.

Problem detection License: MIT (opens in new tab)

#629. ON UPDATE CASCADE is probably not needed (based on column names)

system catalog base tables only

This query identifies foreign key constraints with a superfluous ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing surrogate keys should not permit cascading updates, as their values are immutable by definition. The query uses a naming convention to identify probable surrogate keys, specifically flagging foreign key columns with the prefix or suffix "id". The presence of ON UPDATE CASCADE on such keys is not only unnecessary but also misrepresents the nature of the relationship to a schema observer.

Problem detection License: MIT (opens in new tab)

#630. Optimistic locking routines lacking execution feedback

INFORMATION_SCHEMA+system catalog base tables

This query identifies SQL routines that implement optimistic concurrency control via the xmin system column but fail to provide an execution status to the invoker. Specifically, it flags functions that perform UPDATE or DELETE operations filtered by xmin (a version check) but do not return information regarding the operation's success (e.g., a row count or a BOOLEAN status). This is a critical logic flaw; if a concurrency conflict occurs (the row was modified by another transaction), the operation yields zero rows. Without a return value, the failure is silent, leaving the calling application unaware that the data modification did not occur.

Problem detection License: MIT (opens in new tab)

#631. Optional base table columns

INFORMATION_SCHEMA only

Find optional base table columns, i.e., columns that permit NULLs. Are you sure you want to allow NULLs in these columns?

General License: MIT (opens in new tab)

#632. Optional base table columns that have a default value

INFORMATION_SCHEMA only

This query identifies columns that are both NULLable and have a DEFAULT value. This configuration represents a semantic contradiction: the DEFAULT clause implies that a value should always exist for the column, while the absence of a NOT NULL constraint explicitly permits the absence of a value. The presence of a DEFAULT strongly suggests the column's business logic requires a value, and therefore it should be defined with a NOT NULL constraint to enforce this consistently and make the schema's intent unambiguous.

Problem detection License: MIT (opens in new tab)

#633. Optional columns before mandatory columns

INFORMATION_SCHEMA only

Find cases where optional columns are before a mandatory column. Place mandatory columns before optional columns to improve comprehensibility of the table.

Problem detection License: MIT (opens in new tab)

#634. Optional columns participating in unique keys

INFORMATION_SCHEMA+system catalog base tables

This query identifies optional (nullable) base table columns that participate in a UNIQUE constraint or unique index. In database design, each base table has one or more candidate keys; one is typically selected as the primary key, while the others serve as alternate keys. To properly enforce an alternate key, its underlying UNIQUE constraint should consist entirely of mandatory (NOT NULL) columns, just as primary key columns are. This query highlights columns where this mandatory constraint might be missing, excluding constraints that explicitly use the UNIQUE NULLS NOT DISTINCT clause.

Problem detection License: MIT (opens in new tab)

#635. Optional composite foreign keys that do not have MATCH FULL specified

system catalog base tables only

Find optional composite foreign keys that do not have MATCH FULL specified. Without MATCH FULL the system will permit partial foreign key values

Problem detection License: MIT (opens in new tab)

#636. Optional foreign key columns

INFORMATION_SCHEMA only

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 License: MIT (opens in new tab)

#637. Optional non-foreign columns participating in unique keys

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#638. Ordinal position of primary key columns

INFORMATION_SCHEMA+system catalog base tables

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 License: MIT (opens in new tab)

#639. Overlapping non-function based indexes that have the same leading column but with different operator class

system catalog base tables only

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 License: MIT (opens in new tab)

#640. Overloading

INFORMATION_SCHEMA+system catalog base tables

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 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
621 One true lookup table This query identifies central classifier (reference) tables that store all or most of the system's reference values, along with the dependent tables that reference them. Problem detection system catalog base tables only MIT (opens in new tab) View
622 Only ID primary key Find base base tables have the simple primary key that contains a column with the (case insensitive) name id and an integer type. In addition, the primary key values are generated automatically by the system by using a sequence generator. In addition the base table must not have any unique constraint. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
623 Only one value permitted in a base table or a foreign table column (based on enumeration types) Find columns of base tables or foreign tables in case of which the type of the column permits only one value in the column. The type is an enumeration type that specifies only one value. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
624 ON UPDATE CASCADE is missing (based on classifier tables) This query identifies foreign key constraints referencing classifier tables that lack an ON UPDATE CASCADE clause. Classifier tables hold reference data (e.g., status types, categories). While their rows should not be deleted if they are currently in use, any modifications to their underlying codes should automatically cascade to all dependent tables to maintain data integrity. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
625 ON UPDATE CASCADE is perhaps missing (based on the compensating actions of other foreign key constraints) This query detects inconsistencies in the application of ON UPDATE CASCADE for foreign keys referencing the same candidate key. It identifies sets of foreign key constraints where a proper, non-empty subset is configured with ON UPDATE CASCADE. Such a mixed configuration is a functional flaw, as any attempt to update the parent key will be blocked by the non-cascading constraints, rendering the CASCADE action ineffective and preventing the intended data modification. The principle of atomicity requires that for any given key, either all referencing foreign keys have ON UPDATE CASCADE, or none do. Problem detection system catalog base tables only MIT (opens in new tab) View
626 ON UPDATE CASCADE is probably missing (based on column names) This query identifies foreign key constraints that are likely missing an ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing a natural key should permit cascading updates. The query uses a naming convention to identify probable natural keys, specifically flagging foreign key columns having the suffix or prefix "code" on the assumption that such values are user-defined and may require modification. The absence of ON UPDATE CASCADE on these keys can lead to referential integrity violations when the parent key is updated. Problem detection system catalog base tables only MIT (opens in new tab) View
627 ON UPDATE CASCADE is probably missing (based on data types) This query identifies foreign key constraints that likely require an ON UPDATE CASCADE action. It operates on a strong heuristic based on data type: the query flags foreign keys where the column type is neither integer nor uuid and the ON UPDATE CASCADE action is absent. This assumes that non-numeric, non-UUID keys are natural keys (e.g., VARCHAR, CHAR) whose values are meaningful and may need to be updated over time. The absence of ON UPDATE CASCADE on these relationships can impede data maintenance and violate referential integrity upon updates. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
628 ON UPDATE CASCADE is probably missing (based on the properties of the referenced column) This query identifies foreign key constraints that are likely missing an ON UPDATE CASCADE action on what is inferred to be a simple, integer-based natural key. It isolates referenced keys that are single integer columns, are not themselves foreign keys, and, crucially, have no associated sequence generator. This combination strongly indicates a manually managed key whose values might change. The absence of ON UPDATE CASCADE on such relationships can lead to significant data maintenance issues if the natural key value ever needs to be updated. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
629 ON UPDATE CASCADE is probably not needed (based on column names) This query identifies foreign key constraints with a superfluous ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing surrogate keys should not permit cascading updates, as their values are immutable by definition. The query uses a naming convention to identify probable surrogate keys, specifically flagging foreign key columns with the prefix or suffix "id". The presence of ON UPDATE CASCADE on such keys is not only unnecessary but also misrepresents the nature of the relationship to a schema observer. Problem detection system catalog base tables only MIT (opens in new tab) View
630 Optimistic locking routines lacking execution feedback This query identifies SQL routines that implement optimistic concurrency control via the xmin system column but fail to provide an execution status to the invoker. Specifically, it flags functions that perform UPDATE or DELETE operations filtered by xmin (a version check) but do not return information regarding the operation's success (e.g., a row count or a BOOLEAN status). This is a critical logic flaw; if a concurrency conflict occurs (the row was modified by another transaction), the operation yields zero rows. Without a return value, the failure is silent, leaving the calling application unaware that the data modification did not occur. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
631 Optional base table columns Find optional base table columns, i.e., columns that permit NULLs. Are you sure you want to allow NULLs in these columns? General INFORMATION_SCHEMA only MIT (opens in new tab) View
632 Optional base table columns that have a default value This query identifies columns that are both NULLable and have a DEFAULT value. This configuration represents a semantic contradiction: the DEFAULT clause implies that a value should always exist for the column, while the absence of a NOT NULL constraint explicitly permits the absence of a value. The presence of a DEFAULT strongly suggests the column's business logic requires a value, and therefore it should be defined with a NOT NULL constraint to enforce this consistently and make the schema's intent unambiguous. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
633 Optional columns before mandatory columns Find cases where optional columns are before a mandatory column. Place mandatory columns before optional columns to improve comprehensibility of the table. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
634 Optional columns participating in unique keys This query identifies optional (nullable) base table columns that participate in a UNIQUE constraint or unique index. In database design, each base table has one or more candidate keys; one is typically selected as the primary key, while the others serve as alternate keys. To properly enforce an alternate key, its underlying UNIQUE constraint should consist entirely of mandatory (NOT NULL) columns, just as primary key columns are. This query highlights columns where this mandatory constraint might be missing, excluding constraints that explicitly use the UNIQUE NULLS NOT DISTINCT clause. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
635 Optional composite foreign keys that do not have MATCH FULL specified Find optional composite foreign keys that do not have MATCH FULL specified. Without MATCH FULL the system will permit partial foreign key values Problem detection system catalog base tables only MIT (opens in new tab) View
636 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
637 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
638 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
639 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
640 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