Filter Queries

Found 1096 queries.

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

#81. Base table columns with CITEXT type

system catalog base tables only

Find base table columns with CITEXT type and make sure that case insensitivity is really needed in case of this column.

General License: MIT (opens in new tab)

#82. Base table columns with DECIMAL (p, s) or NUMERIC (p, s) type

INFORMATION_SCHEMA only

Find base table columns with DECIMAL (p, s) or NUMERIC (p, s) type and make sure that precision p and scale s are not too big or too small.

General License: MIT (opens in new tab)

#83. Base table columns with one of the following types: BIGINT, INTEGER, TEXT, or VARCHAR without max character length

INFORMATION_SCHEMA only

Each column should have the most appropriate data type. Developers sometimes misuse BIGINT, INTEGER, TEXT or VARCHAR type in places where a type that permits smaller values would be more appropriate and semantically descriptive.

General License: MIT (opens in new tab)

#84. Base table columns with SMALLINT or BOOLEAN type

INFORMATION_SCHEMA only

Each column should have the most appropriate data type. Developers sometimes forget to use SMALLINT type even if it is logically the best choice. Developers also sometimes forget to use BOOLEAN type and instead invent something.

General License: MIT (opens in new tab)

#85. Base table columns with the same name and type have different field sizes

INFORMATION_SCHEMA only

Find base table columns that have the same name and type but different field size.

Problem detection License: MIT (opens in new tab)

#86. Base table columns with the same name have different types

INFORMATION_SCHEMA only

This query identifies semantic inconsistencies across the database schema by finding base table columns that share the same identifier (name) but are defined with differing data types. According to standard data modeling principles, a shared attribute name implies a shared domain concept (e.g., status_code should consistently be an SMALLINT or a CHAR). Discrepancies in data types for homonymous columns (e.g., is_active being BOOLEAN in one table and SMALLINT in another) hinder interoperability, complicate join logic, and confuse developers.

Problem detection License: MIT (opens in new tab)

#87. Base table columns with the type VARCHAR(1)

INFORMATION_SCHEMA only

The choice of data types should reveal as much as possible about the nature of the data in the column. The type of these columns could be CHAR(1) and they should have a constraint that a value in the column cannot be an empty string.

Problem detection License: MIT (opens in new tab)

#88. Base table columns with UUID type

INFORMATION_SCHEMA only

Each column should have the most appropriate data type. If one does not want to have in a table the surrogate key that values are generated by using a sequence generator, then one may use instead a column with Universally Unique Identifiers as the key column.

General License: MIT (opens in new tab)

#89. Base table FILLFACTOR is not 100

INFORMATION_SCHEMA+system catalog base tables

This query generates a list of all base tables where the FILLFACTOR has been explicitly set to a value other than the default of 100. This non-default setting is a deliberate performance tuning decision, intended to reserve free space within table pages to improve the efficiency of UPDATE operations by facilitating HOT updates. The query provides a comprehensive list for administrators to audit these customizations and verify that they are still necessary and appropriate for the current table workload.

General License: MIT (opens in new tab)

#90. Base table has a national identification number as a key

INFORMATION_SCHEMA+system catalog base tables

This query identifies base table columns whose names suggest they store national identification numbers (personal codes), specifically targeting those that serve as a primary or unique key. Using a national ID as a standalone key enforces a highly restrictive business rule: it assumes that all individuals in the system come from a single country, as identical ID numbers can exist in different countries. The query flags these instances to prompt a review, ensuring that this single-country limitation is intentional and actually aligns with the domain rules.

General License: MIT (opens in new tab)

#91. Base tables and foreign tables that do not have any CHECK constraints on non-foreign key columns

INFORMATION_SCHEMA+system catalog base tables

Identify possibly missing CHECK constraints.

Problem detection License: MIT (opens in new tab)

#92. Base tables and foreign tables that have no CHECK constraints

INFORMATION_SCHEMA only

What are the base tables and foreign tables without any associated (directly or through domains) check constraints? A NOT NULL constraint is a kind of CHECK constraint. However, this query does not take into account NOT NULL constraints.

Problem detection License: MIT (opens in new tab)

#93. Base tables and materialized views without any index

INFORMATION_SCHEMA+system catalog base tables

Find base tables and materialized views that do not have any index.

Problem detection License: MIT (opens in new tab)

#94. Base tables created based on a type

system catalog base tables only

Find base tables that have been created based on a composite type and thnk through as to whether it was really needed.

General License: MIT (opens in new tab)

#95. Base tables that do not have a TOAST table

system catalog base tables only

Find base tables that (due to the types of their columns) do not have an associated TOAST table for storing out-of-line data.

General License: MIT (opens in new tab)

#96. Base tables that have a surrogate key and all its unique constraints have an optional column

INFORMATION_SCHEMA+system catalog base tables

This query identifies tables with a surrogate primary key (an auto-generated, meaningless single-column identifier) that either lack a natural key entirely or have a flawed natural key constraint. A common design mistake when introducing a surrogate key is forgetting to enforce uniqueness on the actual business identifiers (natural keys). Furthermore, if a UNIQUE constraint includes an optional (nullable) column, it fails to prevent duplicate rows. Because NULL evaluates to an unknown state and is not considered equal to another NULL in standard SQL, multiple rows with identical values and NULLs can be inserted. The query flags these vulnerabilities unless the constraint explicitly uses the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULL values as equal.

Problem detection License: MIT (opens in new tab)

#97. Base tables that have a surrogate key and do not have any uniqueness constraints

INFORMATION_SCHEMA+system catalog base tables

This query identifies tables that use a single-column surrogate primary key but lack any other UNIQUE constraints or unique indexes. The absence of additional unique constraints suggests that the natural business key has not been enforced, creating a risk of data duplication that violates business rules. Tables consisting of only a single column are excluded from this check.

Problem detection License: MIT (opens in new tab)

#98. Base tables that have a unique constraint but not the primary key

INFORMATION_SCHEMA+system catalog base tables

This query identifies leaf base tables (tables with no inheriting children) that possess one or more UNIQUE constraints but lack a defined PRIMARY KEY. It is a standard database design best practice to designate one candidate key as the primary key for every table, treating remaining candidate keys as alternate keys. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables.

Problem detection License: MIT (opens in new tab)

#99. Base tables that have more than five indexes

system catalog base tables only

Find base tables that have more than five indexes. Indexes can be used to increase the speed of queries (SELECT statements). However, the amount of indexes shouldn't be too large. Otherwise it may reduce the speed of operations that are used to modify data.

Problem detection License: MIT (opens in new tab)

#100. Base tables that have neither a unique constraint nor the primary key

INFORMATION_SCHEMA+system catalog base tables

This query identifies leaf base tables (tables with no inheriting children) that completely lack both PRIMARY KEY and UNIQUE constraints. It is a standard database design best practice to define at least one candidate key and designate it as the primary key for every table. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Instead, parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables.

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
81 Base table columns with CITEXT type Find base table columns with CITEXT type and make sure that case insensitivity is really needed in case of this column. General system catalog base tables only MIT (opens in new tab) View
82 Base table columns with DECIMAL (p, s) or NUMERIC (p, s) type Find base table columns with DECIMAL (p, s) or NUMERIC (p, s) type and make sure that precision p and scale s are not too big or too small. General INFORMATION_SCHEMA only MIT (opens in new tab) View
83 Base table columns with one of the following types: BIGINT, INTEGER, TEXT, or VARCHAR without max character length Each column should have the most appropriate data type. Developers sometimes misuse BIGINT, INTEGER, TEXT or VARCHAR type in places where a type that permits smaller values would be more appropriate and semantically descriptive. General INFORMATION_SCHEMA only MIT (opens in new tab) View
84 Base table columns with SMALLINT or BOOLEAN type Each column should have the most appropriate data type. Developers sometimes forget to use SMALLINT type even if it is logically the best choice. Developers also sometimes forget to use BOOLEAN type and instead invent something. General INFORMATION_SCHEMA only MIT (opens in new tab) View
85 Base table columns with the same name and type have different field sizes Find base table columns that have the same name and type but different field size. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
86 Base table columns with the same name have different types This query identifies semantic inconsistencies across the database schema by finding base table columns that share the same identifier (name) but are defined with differing data types. According to standard data modeling principles, a shared attribute name implies a shared domain concept (e.g., status_code should consistently be an SMALLINT or a CHAR). Discrepancies in data types for homonymous columns (e.g., is_active being BOOLEAN in one table and SMALLINT in another) hinder interoperability, complicate join logic, and confuse developers. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
87 Base table columns with the type VARCHAR(1) The choice of data types should reveal as much as possible about the nature of the data in the column. The type of these columns could be CHAR(1) and they should have a constraint that a value in the column cannot be an empty string. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
88 Base table columns with UUID type Each column should have the most appropriate data type. If one does not want to have in a table the surrogate key that values are generated by using a sequence generator, then one may use instead a column with Universally Unique Identifiers as the key column. General INFORMATION_SCHEMA only MIT (opens in new tab) View
89 Base table FILLFACTOR is not 100 This query generates a list of all base tables where the FILLFACTOR has been explicitly set to a value other than the default of 100. This non-default setting is a deliberate performance tuning decision, intended to reserve free space within table pages to improve the efficiency of UPDATE operations by facilitating HOT updates. The query provides a comprehensive list for administrators to audit these customizations and verify that they are still necessary and appropriate for the current table workload. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
90 Base table has a national identification number as a key This query identifies base table columns whose names suggest they store national identification numbers (personal codes), specifically targeting those that serve as a primary or unique key. Using a national ID as a standalone key enforces a highly restrictive business rule: it assumes that all individuals in the system come from a single country, as identical ID numbers can exist in different countries. The query flags these instances to prompt a review, ensuring that this single-country limitation is intentional and actually aligns with the domain rules. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
91 Base tables and foreign tables that do not have any CHECK constraints on non-foreign key columns Identify possibly missing CHECK constraints. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
92 Base tables and foreign tables that have no CHECK constraints What are the base tables and foreign tables without any associated (directly or through domains) check constraints? A NOT NULL constraint is a kind of CHECK constraint. However, this query does not take into account NOT NULL constraints. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
93 Base tables and materialized views without any index Find base tables and materialized views that do not have any index. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
94 Base tables created based on a type Find base tables that have been created based on a composite type and thnk through as to whether it was really needed. General system catalog base tables only MIT (opens in new tab) View
95 Base tables that do not have a TOAST table Find base tables that (due to the types of their columns) do not have an associated TOAST table for storing out-of-line data. General system catalog base tables only MIT (opens in new tab) View
96 Base tables that have a surrogate key and all its unique constraints have an optional column This query identifies tables with a surrogate primary key (an auto-generated, meaningless single-column identifier) that either lack a natural key entirely or have a flawed natural key constraint. A common design mistake when introducing a surrogate key is forgetting to enforce uniqueness on the actual business identifiers (natural keys). Furthermore, if a UNIQUE constraint includes an optional (nullable) column, it fails to prevent duplicate rows. Because NULL evaluates to an unknown state and is not considered equal to another NULL in standard SQL, multiple rows with identical values and NULLs can be inserted. The query flags these vulnerabilities unless the constraint explicitly uses 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
97 Base tables that have a surrogate key and do not have any uniqueness constraints This query identifies tables that use a single-column surrogate primary key but lack any other UNIQUE constraints or unique indexes. The absence of additional unique constraints suggests that the natural business key has not been enforced, creating a risk of data duplication that violates business rules. Tables consisting of only a single column are excluded from this check. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
98 Base tables that have a unique constraint but not the primary key This query identifies leaf base tables (tables with no inheriting children) that possess one or more UNIQUE constraints but lack a defined PRIMARY KEY. It is a standard database design best practice to designate one candidate key as the primary key for every table, treating remaining candidate keys as alternate keys. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
99 Base tables that have more than five indexes Find base tables that have more than five indexes. Indexes can be used to increase the speed of queries (SELECT statements). However, the amount of indexes shouldn't be too large. Otherwise it may reduce the speed of operations that are used to modify data. Problem detection system catalog base tables only MIT (opens in new tab) View
100 Base tables that have neither a unique constraint nor the primary key This query identifies leaf base tables (tables with no inheriting children) that completely lack both PRIMARY KEY and UNIQUE constraints. It is a standard database design best practice to define at least one candidate key and designate it as the primary key for every table. Parent tables are specifically excluded from this check because, in PostgreSQL inheritance, primary keys do not enforce global uniqueness across the entire table hierarchy. Instead, parent tables often serve as abstract templates, meaning primary keys are properly defined only on their respective child tables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View