Filter Queries

Found 1077 queries.

Page 38 of 54
  • 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.

#741. 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)

#742. Table has multiple columns for free-form descriptions

INFORMATION_SCHEMA+system catalog base tables

Find tables that contain multiple columns for free-form textual descriptions. Make sure that the names of columns are understandable and sufficiently different. Make sure that there are no duplicate columns.

General License: MIT (opens in new tab)

#743. Table, routine, and usage privileges that have been granted to a superuser

INFORMATION_SCHEMA+system catalog base tables

Find table, routine, and usage privileges that have been granted to a superuser. Superuser can do anything in the database and thus does not need the privileges. The result is a sign that perhaps the executed GRANT statements were incorrect (wrong username) or the grantee later got superuser status (that it shouldn't have).

Problem detection License: MIT (opens in new tab)

#744. Tables without columns

INFORMATION_SCHEMA+system catalog base tables

Do not have in a database elements that are not useful. PostgreSQL permits tables with no columns. Such tables can be used to implement Boolean variables (tables TABLE_DEE and TABLE_DUM). On the other hand, such tables might be a result of database evolution, where developers have not noticed that they have dropped all the columns of a table or have not noticed that they have created such a table in the first place.

Problem detection License: MIT (opens in new tab)

#745. Tables with the same name in different schemas

INFORMATION_SCHEMA+system catalog base tables

Find tables with the same name in different schemas. Make sure that this is not a duplication.

General License: MIT (opens in new tab)

#746. Textual code columns lacking specific pattern validation

INFORMATION_SCHEMA+system catalog base tables

This query identifies semantic validation gaps in textual columns intended to store structured codes. It targets non-foreign key columns whose identifiers imply a specific format (e.g., containing the word "code"), but which lack adequate constraints to enforce that format. Specifically, it flags columns that have either no CHECK constraints at all, or only trivial constraints that prohibit empty/whitespace strings. Since "codes" typically adhere to a strict pattern (e.g., fixed length, specific character set), relying solely on a non-empty check is considered insufficient for data integrity.

Problem detection License: MIT (opens in new tab)

#747. Textual columns that have a secondary index but the operator class for the column does not support pattern matching

INFORMATION_SCHEMA+system catalog base tables

Find indexed textual columns where the indexing does not consider the possibility of pattern-based search. Such columns do not have an index where the used operator class makes the index suitable for use by queries involving pattern matching expressions.

Problem detection License: MIT (opens in new tab)

#748. TG_ARGV is missing

INFORMATION_SCHEMA+system catalog base tables

Write correct code. If you pass arguments to a trigger function, then the function should use the arguments. TG_ARGV[]: "Data type array of text; the arguments from the CREATE TRIGGER statement. The index counts from 0. Invalid indexes (less than 0 or greater than or equal to tg_nargs) result in a null value." (PostgreSQL documentation)

Problem detection License: MIT (opens in new tab)

#749. The generator of surrogate key values can output the same value more than once

INFORMATION_SCHEMA+system catalog base tables

Find surrogate keys where the generator can output the same value more than once. Key values must be unique, i.e., at some point the generator will prevent adding new rows to the table.

Problem detection License: MIT (opens in new tab)

#750. The longest names of database objects

INFORMATION_SCHEMA+system catalog base tables

Find the TOP 3 longest (identifiers) names of user-defined objects.

General License: MIT (opens in new tab)

#751. The longest names of database objects by object type

INFORMATION_SCHEMA+system catalog base tables

"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the TOP 3 longest (identifiers) names of user-defined objects by their type. These could be the first candidates of renaming in order to give to database objects better names.

Sofware measure License: MIT (opens in new tab)

#752. The name of the routine does not match with the action of the routine

INFORMATION_SCHEMA+system catalog base tables

Find user-defined non-trigger SQL and PL/pgSQL routines where the beginning of the name of the routine indicates a certain action inside the routine (INSERT, UPDATE, or DELETE) but there is no such statement in the routine body.

Problem detection License: MIT (opens in new tab)

#753. The number and percentage of different names of database objects

INFORMATION_SCHEMA+system catalog base tables

Names should be expressive. Find the number of different names used in a database as well as the number of named database objects, and the percentage of different names from all the names. Names should be expressive. Different objects should have different names. The smaller the percentage the less descriptive are the names in the database. Find the number of different names (identifiers) of user-defined database objects and compare it with the total number of database objects. The values could be used to compare different databases.

Sofware measure License: MIT (opens in new tab)

#754. The number and percentage of different names of database objects by object type

INFORMATION_SCHEMA+system catalog base tables

"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Different objects should have different names. The smaller the percentage the less descriptive are the names in the database. Find the number of different names (identifiers) of user-defined database objects by the object type and compare it with the total number of database objects with this type. The values could be used to compare different databases.

Sofware measure License: MIT (opens in new tab)

#755. The number of columns based on table type

INFORMATION_SCHEMA+system catalog base tables

Find the total number of columns in the different types of tables as well as average number of columns in the tables as well as minimal and maximal number of columns.

Sofware measure License: MIT (opens in new tab)

#756. The number of commented routines

INFORMATION_SCHEMA+system catalog base tables

Find the number of commented routines based on the way how the comments have been added (as a COMMENT object or as a comment in the routine body).

Sofware measure License: MIT (opens in new tab)

#757. The number of constraints by schema, by type, and in total

INFORMATION_SCHEMA+system catalog base tables

Find the number of constraints in different schemas. The number of constraints in a database gives an indication about the state of enforcing constraints at the database level.

Sofware measure License: MIT (opens in new tab)

#758. The number of derived table columns with an array, a user-defined, XML, JSON, or JSONB type

INFORMATION_SCHEMA+system catalog base tables

Find the number of derived table columns with json, xml, array, or user-defined types. Such columns may contain data that has been aggregated/composed based on values in base tables.

Sofware measure License: MIT (opens in new tab)

#759. The number of names of database objects by the number of subcomponents in the names

INFORMATION_SCHEMA+system catalog base tables

"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the number of names (identifiers) of user-defined database objects by the number of subcomponents in the names. The values could be used to compare different databases.

Sofware measure License: MIT (opens in new tab)

#760. The number of names that use different writing styles

INFORMATION_SCHEMA+system catalog base tables

Find the number of names of user-defined database objects that use snake_case, ALL CAPS, Sentence case, camelCase or PascalCase style. Make sure that the naming style is consistent.

Sofware measure License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(activate to sort ascending) Type(activate to sort ascending) Data source(sorted ascending, activate to sort descending) Last update(activate to sort ascending) License Actions
741 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
742 Table has multiple columns for free-form descriptions Find tables that contain multiple columns for free-form textual descriptions. Make sure that the names of columns are understandable and sufficiently different. Make sure that there are no duplicate columns. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
743 Table, routine, and usage privileges that have been granted to a superuser Find table, routine, and usage privileges that have been granted to a superuser. Superuser can do anything in the database and thus does not need the privileges. The result is a sign that perhaps the executed GRANT statements were incorrect (wrong username) or the grantee later got superuser status (that it shouldn't have). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
744 Tables without columns Do not have in a database elements that are not useful. PostgreSQL permits tables with no columns. Such tables can be used to implement Boolean variables (tables TABLE_DEE and TABLE_DUM). On the other hand, such tables might be a result of database evolution, where developers have not noticed that they have dropped all the columns of a table or have not noticed that they have created such a table in the first place. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
745 Tables with the same name in different schemas Find tables with the same name in different schemas. Make sure that this is not a duplication. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
746 Textual code columns lacking specific pattern validation This query identifies semantic validation gaps in textual columns intended to store structured codes. It targets non-foreign key columns whose identifiers imply a specific format (e.g., containing the word "code"), but which lack adequate constraints to enforce that format. Specifically, it flags columns that have either no CHECK constraints at all, or only trivial constraints that prohibit empty/whitespace strings. Since "codes" typically adhere to a strict pattern (e.g., fixed length, specific character set), relying solely on a non-empty check is considered insufficient for data integrity. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
747 Textual columns that have a secondary index but the operator class for the column does not support pattern matching Find indexed textual columns where the indexing does not consider the possibility of pattern-based search. Such columns do not have an index where the used operator class makes the index suitable for use by queries involving pattern matching expressions. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
748 TG_ARGV is missing Write correct code. If you pass arguments to a trigger function, then the function should use the arguments. TG_ARGV[]: "Data type array of text; the arguments from the CREATE TRIGGER statement. The index counts from 0. Invalid indexes (less than 0 or greater than or equal to tg_nargs) result in a null value." (PostgreSQL documentation) Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
749 The generator of surrogate key values can output the same value more than once Find surrogate keys where the generator can output the same value more than once. Key values must be unique, i.e., at some point the generator will prevent adding new rows to the table. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
750 The longest names of database objects Find the TOP 3 longest (identifiers) names of user-defined objects. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
751 The longest names of database objects by object type "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the TOP 3 longest (identifiers) names of user-defined objects by their type. These could be the first candidates of renaming in order to give to database objects better names. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
752 The name of the routine does not match with the action of the routine Find user-defined non-trigger SQL and PL/pgSQL routines where the beginning of the name of the routine indicates a certain action inside the routine (INSERT, UPDATE, or DELETE) but there is no such statement in the routine body. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
753 The number and percentage of different names of database objects Names should be expressive. Find the number of different names used in a database as well as the number of named database objects, and the percentage of different names from all the names. Names should be expressive. Different objects should have different names. The smaller the percentage the less descriptive are the names in the database. Find the number of different names (identifiers) of user-defined database objects and compare it with the total number of database objects. The values could be used to compare different databases. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
754 The number and percentage of different names of database objects by object type "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Different objects should have different names. The smaller the percentage the less descriptive are the names in the database. Find the number of different names (identifiers) of user-defined database objects by the object type and compare it with the total number of database objects with this type. The values could be used to compare different databases. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
755 The number of columns based on table type Find the total number of columns in the different types of tables as well as average number of columns in the tables as well as minimal and maximal number of columns. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
756 The number of commented routines Find the number of commented routines based on the way how the comments have been added (as a COMMENT object or as a comment in the routine body). Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
757 The number of constraints by schema, by type, and in total Find the number of constraints in different schemas. The number of constraints in a database gives an indication about the state of enforcing constraints at the database level. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
758 The number of derived table columns with an array, a user-defined, XML, JSON, or JSONB type Find the number of derived table columns with json, xml, array, or user-defined types. Such columns may contain data that has been aggregated/composed based on values in base tables. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
759 The number of names of database objects by the number of subcomponents in the names "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the number of names (identifiers) of user-defined database objects by the number of subcomponents in the names. The values could be used to compare different databases. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
760 The number of names that use different writing styles Find the number of names of user-defined database objects that use snake_case, ALL CAPS, Sentence case, camelCase or PascalCase style. Make sure that the naming style is consistent. Sofware measure INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View