Filter Queries

Found 1096 queries.

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

#201. Consistency of comments of routines

INFORMATION_SCHEMA+system catalog base tables

Find user-defined routines that have a comment registered by the COMMENT statement and a comment within the routine body. Make sure that there are no inconsistencies between the comments.

General License: MIT (opens in new tab)

#202. Consistency of using generic column names in candidate key columns that are not foreign key columns

INFORMATION_SCHEMA+system catalog base tables

Find the names on base table columns that are a part of a candidate key but not a foreign key and contain a generic word (nimi, nimetus, kommentaar, kirjeldus, name, comment, description, etc.). Make sure that naming of these is consistent, i.e., such names always contain the table name or never contain the table name.

General License: MIT (opens in new tab)

#203. Consistency of using generic column names in non-candidate key columns that are also not foreign key columns

INFORMATION_SCHEMA+system catalog base tables

Find the names on base table columns that are not a part of a candidate key and a foreign key and contain a generic word (nimi, nimetus, kommentaar, kirjeldus, name, comment, description, etc.). Make sure that naming of these is consistent, i.e., such names always contain the table name or never contain the table name.

General License: MIT (opens in new tab)

#204. Consistency of using NOT NULL constraints on Boolean base table columns

INFORMATION_SCHEMA only

Find the number of mandatory and optional Boolean base table columns and the proportion of optional columns from all the Boolean columns. Use two-valued logic (TRUE, FALSE) instead of three-valued logic (TRUE, FALSE, UNKNOWN). Because NULL in a Boolean column means unknown make all the Boolean columns mandatory.

Sofware measure License: MIT (opens in new tab)

#205. Constraint names missing table identifiers or abbreviations

system catalog base tables only

This query identifies database constraints that do not follow standard naming conventions, specifically those that fail to incorporate either the parent table's full name or an abbreviation formed from the initial letters of its name components (e.g., an acronym). Embedding the table's identity into the constraint name is crucial: it ensures schema-wide uniqueness and provides clear, immediate context when constraint violations are logged or surfaced to end-users.

Problem detection License: MIT (opens in new tab)

#206. Constraints that are not redefined in a subtable

system catalog base tables only

Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation)

Problem detection License: MIT (opens in new tab)

#207. Constraints that are not redefined in a subtable and there is no CHECK constraint that compensates this

INFORMATION_SCHEMA+system catalog base tables

Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Additional condition is that in case of the subtable there is no CHECK that permits only one specific value in the constraint column. The presence of such check would make the design acceptable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation)

Problem detection License: MIT (opens in new tab)

#208. Constraints that are not redefined in a subtable but there is a CHECK constraint that compensates this

INFORMATION_SCHEMA+system catalog base tables

Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Exclude constraints where in case of the subtable there is a CHECK that permits only one specific value in the constraint column. The presence of such check would make the design acceptable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation)

General License: MIT (opens in new tab)

#209. Constraints that are redefined in a subtable.

system catalog base tables only

Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) and have been redefined in its subtable.

General License: MIT (opens in new tab)

#210. Constraint-supporting UNIQUE indexes with the same leading column

system catalog base tables only

Find indexes that support a uniqueness constraint and have the same leading column.

General License: MIT (opens in new tab)

#211. Constraints with the same name within the same schema and constraint type

system catalog base tables only

Find names of foreign key constraints that are used within the same schema more than once. Find names of check constraints that are used within the same schema more than once. Find names of constraint triggers that are used within the same schema more than once. Different things should have different names. But here different constraints have the same name. Also make sure that this is not a sign of duplication.

Problem detection License: MIT (opens in new tab)

#212. Coupling of distinct entity lifecycles via shared state classifiers

system catalog base tables only

This query identifies a potential domain modeling flaw where multiple distinct entity tables reference a single, shared state classifier table. According to robust design principles, each main entity type should define its own independent state machine and lifecycle. Sharing a classifier creates undesirable coupling; even if the state vocabularies (e.g., 'Active', 'Inactive') appear identical currently, the business logic for distinct entities is likely to diverge over time. Furthermore, reliance on a universal state table often indicates an under-analyzed domain model utilizing overly generic state transitions.

Problem detection License: MIT (opens in new tab)

#213. Coverage by derived tables

INFORMATION_SCHEMA+system catalog base tables

Find for each base table the list of derived tables (both views and materialized views) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from the subquery of at least one derived table.

General License: MIT (opens in new tab)

#214. Coverage by routines that have the SQL-standard body

INFORMATION_SCHEMA+system catalog base tables

Find for each base table the list of routines (functions and procedures) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from at least one routine.

General License: MIT (opens in new tab)

#215. Cycle in a hierarchy

system catalog base tables only

There should not be cycles in hierarchies meaning that the parent must always be specified. In this case a parent must reference to a child or to itself, otherwise it cannot be registered.

Problem detection License: MIT (opens in new tab)

#216. Cycles in relationships

INFORMATION_SCHEMA+system catalog base tables

Find as to whether foreign key constraints between tables form a cycle. For instance, if table C refers to table B, table B refers to table A, table A refers to table C and all the foreign key columns are mandatory, then one cannot add data to the tables. Is cycle value in the result should not contain value TRUE. One should check manually as to whether the foreign key columns are mandatory or optional.

Problem detection License: MIT (opens in new tab)

#217. Database can be accessed through PUBLIC privileges

system catalog base tables only

Find as to whether the database access by users (applications) can take place thanks to PUBLIC privileges, i.e., find as to whether PUBLIC (all current and future users) has CONNECT privilege in the database. PUBLIC gets the privilege by default.

Problem detection License: MIT (opens in new tab)

#218. Database connect privilege is missing

INFORMATION_SCHEMA+system catalog base tables

Find non-superusers who have a privilege to use a table or a routine but do not have the privilege to connect to the database.

Problem detection License: MIT (opens in new tab)

#219. Database object identifiers reaching the maximum byte length

INFORMATION_SCHEMA+system catalog base tables

This query identifies user-defined database objects whose identifiers are exactly 63 bytes long. By default, PostgreSQL sets the NAMEDATALEN compile-time constant to 64, making 63 bytes the maximum allowed identifier length. When an identifier exceeds this threshold, PostgreSQL automatically truncates it down to 63 bytes. Names hitting this exact boundary are high-risk indicators of silent truncation: the original identifier was likely longer and was cropped by the engine. This can cause subtle name collisions, break application queries that expect the full name, or corrupt domain semantics.

Problem detection License: MIT (opens in new tab)

#220. Database objects of the same type and case insensitive name in the same container

INFORMATION_SCHEMA+system catalog base tables

This query identifies database objects of the same type within the same schema (or container) that have identical names (and parameters in case of routines) when ignoring case. In SQL databases, this confusing scenario typically occurs when mixing quoted (case-sensitive) and unquoted (case-insensitive) identifiers. For example, a single schema could contain both a table named "Client" and another table named client.

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
201 Consistency of comments of routines Find user-defined routines that have a comment registered by the COMMENT statement and a comment within the routine body. Make sure that there are no inconsistencies between the comments. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
202 Consistency of using generic column names in candidate key columns that are not foreign key columns Find the names on base table columns that are a part of a candidate key but not a foreign key and contain a generic word (nimi, nimetus, kommentaar, kirjeldus, name, comment, description, etc.). Make sure that naming of these is consistent, i.e., such names always contain the table name or never contain the table name. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
203 Consistency of using generic column names in non-candidate key columns that are also not foreign key columns Find the names on base table columns that are not a part of a candidate key and a foreign key and contain a generic word (nimi, nimetus, kommentaar, kirjeldus, name, comment, description, etc.). Make sure that naming of these is consistent, i.e., such names always contain the table name or never contain the table name. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
204 Consistency of using NOT NULL constraints on Boolean base table columns Find the number of mandatory and optional Boolean base table columns and the proportion of optional columns from all the Boolean columns. Use two-valued logic (TRUE, FALSE) instead of three-valued logic (TRUE, FALSE, UNKNOWN). Because NULL in a Boolean column means unknown make all the Boolean columns mandatory. Sofware measure INFORMATION_SCHEMA only MIT (opens in new tab) View
205 Constraint names missing table identifiers or abbreviations This query identifies database constraints that do not follow standard naming conventions, specifically those that fail to incorporate either the parent table's full name or an abbreviation formed from the initial letters of its name components (e.g., an acronym). Embedding the table's identity into the constraint name is crucial: it ensures schema-wide uniqueness and provides clear, immediate context when constraint violations are logged or surfaced to end-users. Problem detection system catalog base tables only MIT (opens in new tab) View
206 Constraints that are not redefined in a subtable Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation) Problem detection system catalog base tables only MIT (opens in new tab) View
207 Constraints that are not redefined in a subtable and there is no CHECK constraint that compensates this Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Additional condition is that in case of the subtable there is no CHECK that permits only one specific value in the constraint column. The presence of such check would make the design acceptable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation) Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
208 Constraints that are not redefined in a subtable but there is a CHECK constraint that compensates this Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) but not in its subtable. Exclude constraints where in case of the subtable there is a CHECK that permits only one specific value in the constraint column. The presence of such check would make the design acceptable. Unfortunately, PostgreSQL table inheritance is implemented in a manner that some constraints (CHECK, NOT NULL) are inherited from the supertable but others are not. "All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited." (PostgreSQL documentation) General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
209 Constraints that are redefined in a subtable. Find primary key, unique, foreign key, and exclude constraints that have been defined in a supertable (parent table) and have been redefined in its subtable. General system catalog base tables only MIT (opens in new tab) View
210 Constraint-supporting UNIQUE indexes with the same leading column Find indexes that support a uniqueness constraint and have the same leading column. General system catalog base tables only MIT (opens in new tab) View
211 Constraints with the same name within the same schema and constraint type Find names of foreign key constraints that are used within the same schema more than once. Find names of check constraints that are used within the same schema more than once. Find names of constraint triggers that are used within the same schema more than once. Different things should have different names. But here different constraints have the same name. Also make sure that this is not a sign of duplication. Problem detection system catalog base tables only MIT (opens in new tab) View
212 Coupling of distinct entity lifecycles via shared state classifiers This query identifies a potential domain modeling flaw where multiple distinct entity tables reference a single, shared state classifier table. According to robust design principles, each main entity type should define its own independent state machine and lifecycle. Sharing a classifier creates undesirable coupling; even if the state vocabularies (e.g., 'Active', 'Inactive') appear identical currently, the business logic for distinct entities is likely to diverge over time. Furthermore, reliance on a universal state table often indicates an under-analyzed domain model utilizing overly generic state transitions. Problem detection system catalog base tables only MIT (opens in new tab) View
213 Coverage by derived tables Find for each base table the list of derived tables (both views and materialized views) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from the subquery of at least one derived table. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
214 Coverage by routines that have the SQL-standard body Find for each base table the list of routines (functions and procedures) that refer to the base table. If the database is used through the public database interface (virtual data layer), then, ideally, each table is referred from at least one routine. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
215 Cycle in a hierarchy There should not be cycles in hierarchies meaning that the parent must always be specified. In this case a parent must reference to a child or to itself, otherwise it cannot be registered. Problem detection system catalog base tables only MIT (opens in new tab) View
216 Cycles in relationships Find as to whether foreign key constraints between tables form a cycle. For instance, if table C refers to table B, table B refers to table A, table A refers to table C and all the foreign key columns are mandatory, then one cannot add data to the tables. Is cycle value in the result should not contain value TRUE. One should check manually as to whether the foreign key columns are mandatory or optional. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
217 Database can be accessed through PUBLIC privileges Find as to whether the database access by users (applications) can take place thanks to PUBLIC privileges, i.e., find as to whether PUBLIC (all current and future users) has CONNECT privilege in the database. PUBLIC gets the privilege by default. Problem detection system catalog base tables only MIT (opens in new tab) View
218 Database connect privilege is missing Find non-superusers who have a privilege to use a table or a routine but do not have the privilege to connect to the database. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
219 Database object identifiers reaching the maximum byte length This query identifies user-defined database objects whose identifiers are exactly 63 bytes long. By default, PostgreSQL sets the NAMEDATALEN compile-time constant to 64, making 63 bytes the maximum allowed identifier length. When an identifier exceeds this threshold, PostgreSQL automatically truncates it down to 63 bytes. Names hitting this exact boundary are high-risk indicators of silent truncation: the original identifier was likely longer and was cropped by the engine. This can cause subtle name collisions, break application queries that expect the full name, or corrupt domain semantics. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
220 Database objects of the same type and case insensitive name in the same container This query identifies database objects of the same type within the same schema (or container) that have identical names (and parameters in case of routines) when ignoring case. In SQL databases, this confusing scenario typically occurs when mixing quoted (case-sensitive) and unquoted (case-insensitive) identifiers. For example, a single schema could contain both a table named "Client" and another table named client. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View