Filter Queries

Found 1092 queries.

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

#401. Granted roles

system catalog base tables only

Find membership relations between roles.

General License: MIT (opens in new tab)

#402. Grantees

INFORMATION_SCHEMA only

Database must be used by users who have minimal set of privileges for performing tasks. The query helps to find out as to whether some user/role other than PUBLIC and a superuser have rights to use tables and routines of the database.

General License: MIT (opens in new tab)

#403. Gratuitous context in the names of foreign key columns

system catalog base tables only

Find foreign key columns that name contains twice the name of the referenced (primary) table.

Problem detection License: MIT (opens in new tab)

#404. Gratuitous context in the names of non-foreign key and non-primary key columns

INFORMATION_SCHEMA+system catalog base tables

This query identifies base table columns that unnecessarily include the table name. It searches for columns that are not part of a primary or foreign key and contain the name of their parent table. To avoid flagging legitimate naming conventions, it explicitly excludes a list of generic column names (e.g., name, description, nimi, kommentaar) where prefixing with the table name is considered good practice for improving clarity in queries.

Problem detection License: MIT (opens in new tab)

#405. Gratuitous context in the names of parameters

INFORMATION_SCHEMA+system catalog base tables

This query enforces a concise coding style by checking the names of parameters within routines (such as functions or procedures). It finds parameters whose names unnecessarily repeat the name of the routine they belong to. For example, in a function named calculate_invoice, a parameter named calculate_invoice_id would be flagged, as invoice_id is sufficient. A routine cannot have two parameters with the same name, so the shorter name is unambiguous within the context of the routine and results in cleaner, more readable code.

Problem detection License: MIT (opens in new tab)

#406. Gratuitous context in the names of schema objects

system catalog base tables only

This query identifies schema objects with names that are redundantly prefixed with their own schema's name. It flags any object whose name begins with the schema name plus at least one other character. This enforces the design principle that a schema is a sufficient namespace, and therefore, objects within it do not require the additional, repetitive context in their own names.

Problem detection License: MIT (opens in new tab)

#407. Identical indexes

system catalog base tables only

Find indexes that are identical, i.e., have the same properties, including uniqueness. The query considers all types of indexes, including indexes that have been automatically created to support a constraint and function-based indexes.

Problem detection License: MIT (opens in new tab)

#408. Identifiers that explicitly say that they carry no meaning

INFORMATION_SCHEMA+system catalog base tables

Find identifiers that explicitly say that they carry no meaning. Such identifier is called "unnamed" or "anonymous".

Problem detection License: MIT (opens in new tab)

#409. Identity columns configured as GENERATED BY DEFAULT

INFORMATION_SCHEMA only

This query identifies identity columns defined with the GENERATED BY DEFAULT clause. Unlike GENERATED ALWAYS, this configuration permits manual insertion of values into the identity column without explicit overrides. This flexibility creates a significant risk of sequence desynchronization: if a user manually inserts a key value that exceeds the current sequence state, the sequence will eventually generate a colliding value. This results in runtime unique constraint violations (primary key conflicts) that are difficult to predict and resolve. The preferred pattern for surrogate keys is typically GENERATED ALWAYS to enforce system-controlled uniqueness.

Problem detection License: MIT (opens in new tab)

#410. Inadequate length constraints on textual code-related columns

INFORMATION_SCHEMA only

This query identifies base table columns designated for storing codes (e.g., vin and isbn codes) that lack appropriate length constraints reflecting real-world data requirements. It operates on a heuristic basis, targeting columns whose identifiers imply code data (e.g., names containing "isbn" or "vin") but whose definitions fail to account for standard maximum lengths. This includes both insufficient allocation (truncation risk) and unbounded allocation (data quality risk). Ensuring these fields are sized according to domain standards is crucial for data integrity and usability.

Problem detection License: MIT (opens in new tab)

#411. Inappropriate field size or data type for column that strores database username

INFORMATION_SCHEMA only

Find columns of base tables that based on the default value of the column contain database username. However, the type of the column is not VARCHAR(63) or VARCHAR(128).

Problem detection License: MIT (opens in new tab)

#412. Inappropriate length constraints for address columns

INFORMATION_SCHEMA only

This query identifies base table columns designated for storing address components (e.g., IP addresses, emails, telephone numbers, or physical locations) that have inappropriate length constraints. It flags columns where the defined field size is either too strict or too loose compared to real-world data requirements. Operating on a heuristic basis, the query targets columns whose names imply address data (e.g., containing 'addr' or 'mail') but whose definitions fail to align with standard lengths. Highlighting both insufficient allocation (truncation risk) and unbounded allocation (data quality risk) helps ensure that these fields are sized according to domain standards, which is crucial for data integrity and usability.

Problem detection License: MIT (opens in new tab)

#413. Inappropriate use of trim function in whitespace constraints

INFORMATION_SCHEMA+system catalog base tables

This query identifies a semantic mismatch between the name and implementation of CHECK constraints (on tables, foreign tables, or domains). It targets constraints whose names suggest they validate against whitespace-only strings (e.g., names containing 'whitespace', 'space', 'blank'), but whose logic inappropriately uses the trim() function. The trim() function is a formatting tool for removing leading/trailing spaces, not a validation tool for ensuring a string is not composed entirely of whitespace. This indicates a likely implementation error, as a more robust regular expression (e.g., column !~ '^\s*$') is the correct tool for this type of validation.

Problem detection License: MIT (opens in new tab)

#414. Inconsistency between the name and the type of a base table column (dates)

INFORMATION_SCHEMA only

Find base table columns that name refers to the possibility that these are used to register dates. Find the columns that do not have an appropriate data type. Column names should reflect the data that is possible to record in the column. For instance, in case of temporal data the column name should indicate as to whether we record dates or timestamps. If the column data type is "date", then the suffix of the column name should be "kp" (Estonian) or "date" (English).

Problem detection License: MIT (opens in new tab)

#415. Inconsistency between the name and the type of a base table column (timestamps)

INFORMATION_SCHEMA only

Find base table columns that name refers to the possibility that these are used to register timestamps. Find the columns that do not have an appropriate data type. Column names should reflect the data that is possible to record in the column. For instance, in case of temporal data the column name should indicate as to whether we record dates or timestamps. If the column type is "timestamp", then the suffix of the column name should be "aeg" (Estonian) or "time" (English).

Problem detection License: MIT (opens in new tab)

#416. Inconsistency between the type and the default value of a column (date and timestamp values)

INFORMATION_SCHEMA only

Find table columns with timestamp/date types that data type and dynamically found default value have a different type.

Problem detection License: MIT (opens in new tab)

#417. Inconsistency between the type and the default value of a column (time values)

INFORMATION_SCHEMA only

Find table columns with time types, which data type and dynamically found default value have a different type.

Problem detection License: MIT (opens in new tab)

#418. Inconsistency (code vs. id) of naming foreign key and referenced candidate key columns

system catalog base tables only

Naming of foreign key and referenced candidate key columns should be consistent. It cannot be so that in one table a value is labeled "id" like some surrogate key value and in another it "turns" into human-usable "code" or vice versa. An example:

Person(person_id, name)
Primary Key (person_id)

E_mail_address(e_mail_address_id, person_code, address)
Primary Key (e_mail_address_id)
Foreign key (person_code) References Person (person_id)

Problem detection License: MIT (opens in new tab)

#419. Inconsistency of using column data types/field sizes in case of columns that implement relationships

INFORMATION_SCHEMA+system catalog base tables

Find foreign key constraints where the candidate key columns (belong to a PRIMARY KEY/UNIQUE constraint) and foreign key columns do not have the same data type and field size. Primary key/unique columns and foreign key columns should have the same data type and field size. If, for instance, the primary key column has type INTEGER and foreign key column has type SMALLINT, then one cannot use all the primary key values as foreign key values.

Problem detection License: MIT (opens in new tab)

#420. Inconsistency of using parameter data types

INFORMATION_SCHEMA+system catalog base tables

Find parameters of routines that have the same name but a different type. Parameters that have the same name should have, in general, the same data type as well, assuming that the routines, which have the parameters, have different names, i.e., there is no overloading in play.

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
401 Granted roles Find membership relations between roles. General system catalog base tables only MIT (opens in new tab) View
402 Grantees Database must be used by users who have minimal set of privileges for performing tasks. The query helps to find out as to whether some user/role other than PUBLIC and a superuser have rights to use tables and routines of the database. General INFORMATION_SCHEMA only MIT (opens in new tab) View
403 Gratuitous context in the names of foreign key columns Find foreign key columns that name contains twice the name of the referenced (primary) table. Problem detection system catalog base tables only MIT (opens in new tab) View
404 Gratuitous context in the names of non-foreign key and non-primary key columns This query identifies base table columns that unnecessarily include the table name. It searches for columns that are not part of a primary or foreign key and contain the name of their parent table. To avoid flagging legitimate naming conventions, it explicitly excludes a list of generic column names (e.g., name, description, nimi, kommentaar) where prefixing with the table name is considered good practice for improving clarity in queries. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
405 Gratuitous context in the names of parameters This query enforces a concise coding style by checking the names of parameters within routines (such as functions or procedures). It finds parameters whose names unnecessarily repeat the name of the routine they belong to. For example, in a function named calculate_invoice, a parameter named calculate_invoice_id would be flagged, as invoice_id is sufficient. A routine cannot have two parameters with the same name, so the shorter name is unambiguous within the context of the routine and results in cleaner, more readable code. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
406 Gratuitous context in the names of schema objects This query identifies schema objects with names that are redundantly prefixed with their own schema's name. It flags any object whose name begins with the schema name plus at least one other character. This enforces the design principle that a schema is a sufficient namespace, and therefore, objects within it do not require the additional, repetitive context in their own names. Problem detection system catalog base tables only MIT (opens in new tab) View
407 Identical indexes Find indexes that are identical, i.e., have the same properties, including uniqueness. The query considers all types of indexes, including indexes that have been automatically created to support a constraint and function-based indexes. Problem detection system catalog base tables only MIT (opens in new tab) View
408 Identifiers that explicitly say that they carry no meaning Find identifiers that explicitly say that they carry no meaning. Such identifier is called "unnamed" or "anonymous". Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
409 Identity columns configured as GENERATED BY DEFAULT This query identifies identity columns defined with the GENERATED BY DEFAULT clause. Unlike GENERATED ALWAYS, this configuration permits manual insertion of values into the identity column without explicit overrides. This flexibility creates a significant risk of sequence desynchronization: if a user manually inserts a key value that exceeds the current sequence state, the sequence will eventually generate a colliding value. This results in runtime unique constraint violations (primary key conflicts) that are difficult to predict and resolve. The preferred pattern for surrogate keys is typically GENERATED ALWAYS to enforce system-controlled uniqueness. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
410 Inadequate length constraints on textual code-related columns This query identifies base table columns designated for storing codes (e.g., vin and isbn codes) that lack appropriate length constraints reflecting real-world data requirements. It operates on a heuristic basis, targeting columns whose identifiers imply code data (e.g., names containing "isbn" or "vin") but whose definitions fail to account for standard maximum lengths. This includes both insufficient allocation (truncation risk) and unbounded allocation (data quality risk). Ensuring these fields are sized according to domain standards is crucial for data integrity and usability. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
411 Inappropriate field size or data type for column that strores database username Find columns of base tables that based on the default value of the column contain database username. However, the type of the column is not VARCHAR(63) or VARCHAR(128). Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
412 Inappropriate length constraints for address columns This query identifies base table columns designated for storing address components (e.g., IP addresses, emails, telephone numbers, or physical locations) that have inappropriate length constraints. It flags columns where the defined field size is either too strict or too loose compared to real-world data requirements. Operating on a heuristic basis, the query targets columns whose names imply address data (e.g., containing 'addr' or 'mail') but whose definitions fail to align with standard lengths. Highlighting both insufficient allocation (truncation risk) and unbounded allocation (data quality risk) helps ensure that these fields are sized according to domain standards, which is crucial for data integrity and usability. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
413 Inappropriate use of trim function in whitespace constraints This query identifies a semantic mismatch between the name and implementation of CHECK constraints (on tables, foreign tables, or domains). It targets constraints whose names suggest they validate against whitespace-only strings (e.g., names containing 'whitespace', 'space', 'blank'), but whose logic inappropriately uses the trim() function. The trim() function is a formatting tool for removing leading/trailing spaces, not a validation tool for ensuring a string is not composed entirely of whitespace. This indicates a likely implementation error, as a more robust regular expression (e.g., column !~ '^\s*$') is the correct tool for this type of validation. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
414 Inconsistency between the name and the type of a base table column (dates) Find base table columns that name refers to the possibility that these are used to register dates. Find the columns that do not have an appropriate data type. Column names should reflect the data that is possible to record in the column. For instance, in case of temporal data the column name should indicate as to whether we record dates or timestamps. If the column data type is "date", then the suffix of the column name should be "kp" (Estonian) or "date" (English). Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
415 Inconsistency between the name and the type of a base table column (timestamps) Find base table columns that name refers to the possibility that these are used to register timestamps. Find the columns that do not have an appropriate data type. Column names should reflect the data that is possible to record in the column. For instance, in case of temporal data the column name should indicate as to whether we record dates or timestamps. If the column type is "timestamp", then the suffix of the column name should be "aeg" (Estonian) or "time" (English). Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
416 Inconsistency between the type and the default value of a column (date and timestamp values) Find table columns with timestamp/date types that data type and dynamically found default value have a different type. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
417 Inconsistency between the type and the default value of a column (time values) Find table columns with time types, which data type and dynamically found default value have a different type. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
418 Inconsistency (code vs. id) of naming foreign key and referenced candidate key columns Naming of foreign key and referenced candidate key columns should be consistent. It cannot be so that in one table a value is labeled "id" like some surrogate key value and in another it "turns" into human-usable "code" or vice versa. An example:

Person(person_id, name)
Primary Key (person_id)

E_mail_address(e_mail_address_id, person_code, address)
Primary Key (e_mail_address_id)
Foreign key (person_code) References Person (person_id)
Problem detection system catalog base tables only MIT (opens in new tab) View
419 Inconsistency of using column data types/field sizes in case of columns that implement relationships Find foreign key constraints where the candidate key columns (belong to a PRIMARY KEY/UNIQUE constraint) and foreign key columns do not have the same data type and field size. Primary key/unique columns and foreign key columns should have the same data type and field size. If, for instance, the primary key column has type INTEGER and foreign key column has type SMALLINT, then one cannot use all the primary key values as foreign key values. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
420 Inconsistency of using parameter data types Find parameters of routines that have the same name but a different type. Parameters that have the same name should have, in general, the same data type as well, assuming that the routines, which have the parameters, have different names, i.e., there is no overloading in play. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View