Filter Queries

Found 1053 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 relatively small amount of data, which is in the system catalog of a database.
  • Statistics about the catalog content and project home in GitHub that has additional information.

#861. STATEMENT level triggers and ROW level AFTER triggers without RETURN NULL

INFORMATION_SCHEMA+system catalog base tables

Write correct code "The return value of a row-level trigger fired AFTER or a statement-level trigger fired BEFORE or AFTER is always ignored; it might as well be null." (PostgreSQL documentation)

Problem detection License: MIT (opens in new tab)

#862. STATEMENT level triggers that refer to the values of row variables NEW or OLD

INFORMATION_SCHEMA+system catalog base tables

Find STATEMENT level triggers that refer to the values of row variables NEW or OLD. NEW and OLD are special variables that can only be used in row-level trigger procedures.

Problem detection License: MIT (opens in new tab)

#863. Stating the obvious

INFORMATION_SCHEMA+system catalog base tables

Find database objects that name contains words "data" or "info". These are noise words because databases are meant for storing and manipulating data/information.

Problem detection License: MIT (opens in new tab)

#864. Stating the obvious (2)

INFORMATION_SCHEMA+system catalog base tables

Find the names of database objects where the name of the database object contains a part of the name of the object type. For instance, the query finds base tables, were the name contains fragments _base, base_, _table, or table_.

Problem detection License: MIT (opens in new tab)

#865. Stating the obvious (column names)

INFORMATION_SCHEMA only

Find the names of columns where the name of the column contains a part of the name of the data type of the column. For instance, the query finds columns, were the name contains fragments integer_ or _integer.

Problem detection License: MIT (opens in new tab)

#866. Storing a duration as time

INFORMATION_SCHEMA only

Find columns of base and foreign tables that based on the column names are used to register durations but the type of the column is time. "It is possible to use a TIME data type if the duration is less than 24 hours, but this is not what the type is intended for, and can be the cause of confusion for the next person who has to maintain your code."

Problem detection License: MIT (opens in new tab)

#867. Storing a duration rather than a point in time

INFORMATION_SCHEMA only

Find columns of base and foreign tables that based on the column names and types are used to register start time and duration rather than start time and end time.

Problem detection License: MIT (opens in new tab)

#868. Storing file content in the database

INFORMATION_SCHEMA only

Find columns that probably store content of files in the database.

General License: MIT (opens in new tab)

#869. Subqueries of derived tables with LIMIT/FETCH/DISTINCT ON without ORDER BY

INFORMATION_SCHEMA+system catalog base tables

Find subqueries of derived tables (views, materialized views) with the LIMIT/FETCH clause or with DISTINCT ON construct but without the ORDER BY clause. These constructs require sorting to produce a meaningful result.

Problem detection License: MIT (opens in new tab)

#870. Surrogate key columns

INFORMATION_SCHEMA+system catalog base tables

Find surrogate keys. Surrogate key is a key that consist of one column, which has an integer type. The key has been declared by using PRIMARY KEY or UNIQUE constraint. The column is associated with a sequence generator (either external or internal, i.e., created by the system automatically because the column has been declared as an identity column). The column does not participate in any foreign key.

General License: MIT (opens in new tab)

#871. Surrogate key columns that do not follow the naming style

INFORMATION_SCHEMA+system catalog base tables

Find surrogate key columns that name does not end with "id_" or start with "id_".

Problem detection License: MIT (opens in new tab)

#872. System-generated domain CHECK constraint names

INFORMATION_SCHEMA only

Find the names of domain CHECK constraints that have been system-generated. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different.

Problem detection License: MIT (opens in new tab)

#873. System-generated table constraint names (constraints that involve one column)

system catalog base tables only

Find the names of database constraints that have been system-generated. Additional restrictions are that the constraints must involve only one column and are associated directly with a table (not through a domain). Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different.

Problem detection License: MIT (opens in new tab)

#874. Table check constraints with regular expressions

INFORMATION_SCHEMA only

Find all CHECK constraints (except NOT NULL) that are associated with a base table or a foreign table column and use a regular expression. It is useful to enforce as many constraints at database level as possible. In this way one improves data quality as well as gives extra information to the database users (including the DBMS engines, development environments, and applications).

General License: MIT (opens in new tab)

#875. Table columns that are associated with a sequence generator

INFORMATION_SCHEMA only

Surrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there is no usage of sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys.

General License: MIT (opens in new tab)

#876. Table columns with NOT VALID CHECK constraints

INFORMATION_SCHEMA only

Find CHECK constraints of base table and foreign table columns that are not valid. These constraints have been created so that the existing data has not been checked against the constraint. It could be deliberate in case of legacy systems that have data quality problems. However, ideally all the data in the table conforms to the constraint.

Problem detection License: MIT (opens in new tab)

#877. Table constraints with the cardinality bigger than one

system catalog base tables only

Find constraints that involve more than one columns. Check as to whether the names follow a common style or not.

General License: MIT (opens in new tab)

#878. Table constraints with the same name (constraints connected directly with a base table or a foreign table)

system catalog base tables only

Find base table and foreign table constraint names that are used in a database more than once (possibly in different schemas or in case of different types of constraints). 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)

#879. Table functions with OFFSET

INFORMATION_SCHEMA+system catalog base tables

Find table functions that use OFFSET. OFFSET method is a common way for implementing pagination.

Problem detection License: MIT (opens in new tab)

#880. Table has both state and status columns

INFORMATION_SCHEMA+system catalog base tables

Find tables that contain both a state and a status column.

General License: MIT (opens in new tab)
# Name Goal Type Data source Last update (sorted descending) License Actions
861 STATEMENT level triggers and ROW level AFTER triggers without RETURN NULL Write correct code "The return value of a row-level trigger fired AFTER or a statement-level trigger fired BEFORE or AFTER is always ignored; it might as well be null." (PostgreSQL documentation) Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
862 STATEMENT level triggers that refer to the values of row variables NEW or OLD Find STATEMENT level triggers that refer to the values of row variables NEW or OLD. NEW and OLD are special variables that can only be used in row-level trigger procedures. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
863 Stating the obvious Find database objects that name contains words "data" or "info". These are noise words because databases are meant for storing and manipulating data/information. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
864 Stating the obvious (2) Find the names of database objects where the name of the database object contains a part of the name of the object type. For instance, the query finds base tables, were the name contains fragments _base, base_, _table, or table_. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
865 Stating the obvious (column names) Find the names of columns where the name of the column contains a part of the name of the data type of the column. For instance, the query finds columns, were the name contains fragments integer_ or _integer. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
866 Storing a duration as time Find columns of base and foreign tables that based on the column names are used to register durations but the type of the column is time. "It is possible to use a TIME data type if the duration is less than 24 hours, but this is not what the type is intended for, and can be the cause of confusion for the next person who has to maintain your code." Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
867 Storing a duration rather than a point in time Find columns of base and foreign tables that based on the column names and types are used to register start time and duration rather than start time and end time. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
868 Storing file content in the database Find columns that probably store content of files in the database. General INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
869 Subqueries of derived tables with LIMIT/FETCH/DISTINCT ON without ORDER BY Find subqueries of derived tables (views, materialized views) with the LIMIT/FETCH clause or with DISTINCT ON construct but without the ORDER BY clause. These constructs require sorting to produce a meaningful result. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
870 Surrogate key columns Find surrogate keys. Surrogate key is a key that consist of one column, which has an integer type. The key has been declared by using PRIMARY KEY or UNIQUE constraint. The column is associated with a sequence generator (either external or internal, i.e., created by the system automatically because the column has been declared as an identity column). The column does not participate in any foreign key. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
871 Surrogate key columns that do not follow the naming style Find surrogate key columns that name does not end with "id_" or start with "id_". Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
872 System-generated domain CHECK constraint names Find the names of domain CHECK constraints that have been system-generated. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
873 System-generated table constraint names (constraints that involve one column) Find the names of database constraints that have been system-generated. Additional restrictions are that the constraints must involve only one column and are associated directly with a table (not through a domain). Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
874 Table check constraints with regular expressions Find all CHECK constraints (except NOT NULL) that are associated with a base table or a foreign table column and use a regular expression. It is useful to enforce as many constraints at database level as possible. In this way one improves data quality as well as gives extra information to the database users (including the DBMS engines, development environments, and applications). General INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
875 Table columns that are associated with a sequence generator Surrogate key values must be generated by using the system (the sequence generator mechanism in case of PostgreSQL). If there is no usage of sequence generators, then there is a question as to whether there are no surrogate keys in the database at all (could be possible and OK) or (more probable) developers have forgotten to implement the generation of surrogate keys. General INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
876 Table columns with NOT VALID CHECK constraints Find CHECK constraints of base table and foreign table columns that are not valid. These constraints have been created so that the existing data has not been checked against the constraint. It could be deliberate in case of legacy systems that have data quality problems. However, ideally all the data in the table conforms to the constraint. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
877 Table constraints with the cardinality bigger than one Find constraints that involve more than one columns. Check as to whether the names follow a common style or not. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)
878 Table constraints with the same name (constraints connected directly with a base table or a foreign table) Find base table and foreign table constraint names that are used in a database more than once (possibly in different schemas or in case of different types of constraints). 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 (opens in new tab)
879 Table functions with OFFSET Find table functions that use OFFSET. OFFSET method is a common way for implementing pagination. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
880 Table has both state and status columns Find tables that contain both a state and a status column. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)