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.
#181. Row-level triggers with RETURN NULL cancellation logic
INFORMATION_SCHEMA+system catalog base tablesThis query identifies row-level BEFORE and INSTEAD OF triggers that explicitly RETURN NULL. In PostgreSQL's trigger execution model, this return value acts as a cancellation signal. For BEFORE triggers on tables, it aborts the operation for the current row, preventing the INSERT, UPDATE, or DELETE and suppressing subsequent triggers. For INSTEAD OF triggers on views, it signals that no modification was performed. While this behavior can be used for conditional logic (e.g., silently ignoring invalid rows), it presents a risk of unintended data loss or logic errors if used incorrectly. These triggers should be audited to ensure the cancellation behavior is intentional and correctly implemented.
#182. Rules with the same name in different schemas
system catalog base tables onlyFind rule names that are used in a database in more than one schema. Different things should have different names. But here different rules have the same name. Also make sure that this is not a duplication.
#183. Set operations that do not remove duplicate rows in derived tables
INFORMATION_SCHEMA+system catalog base tablesFind derived tables (views and materialized views) that use a set theoretic operation (union, except or intersect) in a manner that does not remove duplicate rows and thus can produce a multiset not a set. Make sure that it is what is needed.
#184. Single-column natural primary keys
INFORMATION_SCHEMA+system catalog base tablesThis query identifies primary keys that consist of a single column and are not system-generated (i.e., they are not associated with a sequence or defined as IDENTITY columns). This pattern is characteristic of a natural primary key, where the key's value is derived from a real-world, user-defined attribute rather than an arbitrary surrogate value. Identifying these keys is crucial for auditing a data model's key strategy and understanding its reliance on meaningful, potentially mutable, business data for entity identification.
#185. Small tables
INFORMATION_SCHEMA+system catalog base tablesFind tables that have one column or zero columns.
#186. Storing file content in the database
INFORMATION_SCHEMA onlyFind columns that probably store content of files in the database.
#187. Surrogate key columns
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#188. Table check constraints with regular expressions
INFORMATION_SCHEMA onlyFind 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).
#189. Table columns that are associated with a sequence generator
INFORMATION_SCHEMA onlySurrogate 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.
#190. Table constraints with the cardinality bigger than one
system catalog base tables onlyFind constraints that involve more than one columns. Check as to whether the names follow a common style or not.
#191. Table has both state and status columns
INFORMATION_SCHEMA+system catalog base tablesFind tables that contain both a state and a status column.
#192. Table has multiple columns for free-form descriptions
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#193. Table inheritance
system catalog base tables onlyFind inheritance between base tables. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables.
#194. Table inheritance (path view)
system catalog base tables onlyFind in case of each base table that participates in a table inheritance hierarchy the path to the table from the top-level table. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables. Also make sure that the identifier of each child table in an inheritance hierarchy is a hyponym of the identifier of its parent table.
#195. Table privileges
INFORMATION_SCHEMA onlyCheck as to whether there are no unnecessary privileges.
#196. Tables that have associated user triggers
system catalog base tables onlyFind information about tables that are associated with triggers.
#197. Tables with the same name in different schemas
INFORMATION_SCHEMA+system catalog base tablesFind tables with the same name in different schemas. Make sure that this is not a duplication.
#198. The longest names of database objects
INFORMATION_SCHEMA+system catalog base tablesFind the TOP 3 longest (identifiers) names of user-defined objects.
#199. The same database object name is used repeatedly in case the same database object type
INFORMATION_SCHEMA+system catalog base tablesFind what database object names are used more than once in case the objects of the same type. If the names differ from each other only by digits or underscores, then consider these the same name. For instance, if there are base tables Person and Person2 (in the same schema or different schemas), then the query returns the name Person. Make sure that there is no duplication of implementation elements in the database.
#200. The same trigger function is used in case of multiple tables
INFORMATION_SCHEMA onlyFind trigger functions that are used in case of more than one table. Although it is legal, one must be careful when changing the functions in order to avoid unwanted consequences.
| # | Name | Goal | Type (sorted ascending) | Data source | Last update | License | Actions |
|---|---|---|---|---|---|---|---|
| 181 | Row-level triggers with RETURN NULL cancellation logic | This query identifies row-level BEFORE and INSTEAD OF triggers that explicitly RETURN NULL. In PostgreSQL's trigger execution model, this return value acts as a cancellation signal. For BEFORE triggers on tables, it aborts the operation for the current row, preventing the INSERT, UPDATE, or DELETE and suppressing subsequent triggers. For INSTEAD OF triggers on views, it signals that no modification was performed. While this behavior can be used for conditional logic (e.g., silently ignoring invalid rows), it presents a risk of unintended data loss or logic errors if used incorrectly. These triggers should be audited to ensure the cancellation behavior is intentional and correctly implemented. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 182 | Rules with the same name in different schemas | Find rule names that are used in a database in more than one schema. Different things should have different names. But here different rules have the same name. Also make sure that this is not a duplication. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 183 | Set operations that do not remove duplicate rows in derived tables | Find derived tables (views and materialized views) that use a set theoretic operation (union, except or intersect) in a manner that does not remove duplicate rows and thus can produce a multiset not a set. Make sure that it is what is needed. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 184 | Single-column natural primary keys | This query identifies primary keys that consist of a single column and are not system-generated (i.e., they are not associated with a sequence or defined as IDENTITY columns). This pattern is characteristic of a natural primary key, where the key's value is derived from a real-world, user-defined attribute rather than an arbitrary surrogate value. Identifying these keys is crucial for auditing a data model's key strategy and understanding its reliance on meaningful, potentially mutable, business data for entity identification. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 185 | Small tables | Find tables that have one column or zero columns. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 186 | 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) | |
| 187 | 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) | |
| 188 | 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) | |
| 189 | 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) | |
| 190 | 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) | |
| 191 | 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) | |
| 192 | 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 (opens in new tab) | |
| 193 | Table inheritance | Find inheritance between base tables. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 194 | Table inheritance (path view) | Find in case of each base table that participates in a table inheritance hierarchy the path to the table from the top-level table. Use table inheritance carefully because, for instance, certain constraints are not inherited and must be redefined on child tables. Also make sure that the identifier of each child table in an inheritance hierarchy is a hyponym of the identifier of its parent table. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 195 | Table privileges | Check as to whether there are no unnecessary privileges. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View (opens in new tab) | |
| 196 | Tables that have associated user triggers | Find information about tables that are associated with triggers. | General | system catalog base tables only | MIT (opens in new tab) | View (opens in new tab) | |
| 197 | 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 (opens in new tab) | |
| 198 | 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 (opens in new tab) | |
| 199 | The same database object name is used repeatedly in case the same database object type | Find what database object names are used more than once in case the objects of the same type. If the names differ from each other only by digits or underscores, then consider these the same name. For instance, if there are base tables Person and Person2 (in the same schema or different schemas), then the query returns the name Person. Make sure that there is no duplication of implementation elements in the database. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View (opens in new tab) | |
| 200 | The same trigger function is used in case of multiple tables | Find trigger functions that are used in case of more than one table. Although it is legal, one must be careful when changing the functions in order to avoid unwanted consequences. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View (opens in new tab) |