Filter Queries

Found 1077 queries.

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

#861. Validation triggers reading reference tables without FOR SHARE locking

INFORMATION_SCHEMA+system catalog base tables

This query identifies row-level BEFORE triggers that validate data by querying other tables (SELECT ... FROM ... WHERE) before raising an exception, but fail to acquire a shared lock (FOR SHARE) on the referenced rows. Under PostgreSQL's default READ COMMITTED isolation level, reading a reference or classifier row (such as checking whether a status, category, or type is active) without FOR SHARE allows concurrent transactions to deactivate or modify that reference row before the triggering transaction commits, leading to write skew and data integrity violations.

Problem detection License: MIT (opens in new tab)

#862. Very similar (but not equal) routine names

INFORMATION_SCHEMA+system catalog base tables

This query audits the schema for semantic ambiguity by identifying pairs of routine names (functions, procedures) that exhibit high textual similarity but are not identical. It filters for name pairs with a Levenshtein edit distance of exactly one (less than two, but excluding equality). This specific filter targets typographical errors (e.g., calc_tax vs. calc_tux) or inconsistent singular/plural naming (e.g., get_user vs. get_users), while correctly ignoring valid method overloading where names are identical.

Problem detection License: MIT (opens in new tab)

#863. Very similar column names

INFORMATION_SCHEMA+system catalog base tables

This query performs an intra-table analysis to detect potential schema ambiguities. It identifies pairs of columns within the same table that exhibit both high textual similarity and structural equivalence. Specifically, it flags pairs where the names have a Levenshtein edit distance of exactly one and the columns share the same data type or domain. This combination suggests a high probability of typographical errors (e.g., status vs statuss), inconsistent naming (singular vs. plural), or improper denormalization (e.g., item1 vs item2), all of which undermine schema clarity.

Problem detection License: MIT (opens in new tab)

#864. Very similar table names

INFORMATION_SCHEMA+system catalog base tables

This query identifies potential redundancy or ambiguity in the schema by detecting pairs of table names with high textual similarity. It utilizes the Levenshtein distance algorithm to find name pairs that differ by fewer than two characters (i.e., a distance of 0 or 1). This check applies across different types of tables (base tables, foreign tables, derived tables), helping to uncover typographical errors (e.g., users vs user), inconsistent pluralization, or confusingly named entities that violate the principle of distinct and descriptive identifiers.

Problem detection License: MIT (opens in new tab)

#865. Views without security barrier

INFORMATION_SCHEMA+system catalog base tables

Find views that do not have the security barrier option.

Problem detection License: MIT (opens in new tab)

#866. Views with unnecessary security invoker

INFORMATION_SCHEMA+system catalog base tables

Find views with security invoker option that do not have any underlying base table with a security policy. Security invoker option of views is possible starting from PostgreSQL 15. "The main use case (and the one that inspired the feature) is to be able to use views and still check row-level security policies on the underlying tables as the invoker."

Problem detection License: MIT (opens in new tab)

#867. Views with WHERE but without security barrier

INFORMATION_SCHEMA+system catalog base tables

Find views that do not have the security barrier option but restrict rows in some way.

Problem detection License: MIT (opens in new tab)

#868. All clustered indexes

system catalog base tables only

Find all tables that rows have been physically sorted based on an index.

General License: MIT (opens in new tab)

#869. All database privileges

system catalog base tables only

Find the privileges to use the database. c - CONNECT; C - CREATE; T - TEMPORARY.

General License: MIT (opens in new tab)

#870. All event triggers

system catalog base tables only

Find event triggers, which are not associated to a specific schema object.

General License: MIT (opens in new tab)

#871. All exclude constraints

system catalog base tables only

Find all exclude constraints.

General License: MIT (opens in new tab)

#872. All foreign key constraints

system catalog base tables only

Enforce referential integrity in database. Find all referential integrity (foreign key) constraints.

General License: MIT (opens in new tab)

#873. All identifying relationships

system catalog base tables only

Find all non-identifying relationships where the foreign key (a set of columns) is a subset of a uniqueness constraint (primary key, unique, or exclude constraint).

General License: MIT (opens in new tab)

#874. All key constraints

system catalog base tables only

This query retrieves a comprehensive list of all PRIMARY KEY and UNIQUE constraints defined on base tables within the database. These constraints are the fundamental mechanisms for enforcing entity integrity and uniqueness. The output provides essential information for schema auditing, documentation generation, and analyzing the data model's key structures. It allows administrators and developers to quickly verify how uniqueness is enforced for each table.

General License: MIT (opens in new tab)

#875. All non-identifying relationships

system catalog base tables only

Find all non-identifying relationships where the foreign key (a set of columns) is not a subset of any uniqueness constraint (primary key, unique, or exclude constraint).

General License: MIT (opens in new tab)

#876. All rules

system catalog base tables only

Find user-defined rules for rewriting data manipulation language statements. Rules should be used only for the tasks that cannot be achieved in a declarative manner, i.e., for example, by declaring a constraint.

General License: MIT (opens in new tab)

#877. All security policies

system catalog base tables only

Find all security policies.

General License: MIT (opens in new tab)

#878. All supertables

system catalog base tables only

Find all the base tables that serve as supertables in the inheritance hierarchies

Sofware measure License: MIT (opens in new tab)

#879. All system-defined TOAST-able types

system catalog base tables only

Find system-defined types in case of which the system can use the TOAST technique, i.e., save the value in a compressed form or store it in a automatically-created secondary table, which is hidden from the database user (TOAST table).

General License: MIT (opens in new tab)

#880. All uniqueness constraints where nulls are not distinct

system catalog base tables only

This query identifies UNIQUE constraints that explicitly use the NULLS NOT DISTINCT clause. Introduced in PostgreSQL 15, this modifier changes standard SQL behavior by treating NULL values as equal, thereby preventing multiple identical rows that contain NULLs. This query is useful for auditing the schema to review where this specific null-handling logic is applied, ensuring it aligns with business rules, or flagging it for environments that require compatibility with older PostgreSQL versions

General 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
861 Validation triggers reading reference tables without FOR SHARE locking This query identifies row-level BEFORE triggers that validate data by querying other tables (SELECT ... FROM ... WHERE) before raising an exception, but fail to acquire a shared lock (FOR SHARE) on the referenced rows. Under PostgreSQL's default READ COMMITTED isolation level, reading a reference or classifier row (such as checking whether a status, category, or type is active) without FOR SHARE allows concurrent transactions to deactivate or modify that reference row before the triggering transaction commits, leading to write skew and data integrity violations. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
862 Very similar (but not equal) routine names This query audits the schema for semantic ambiguity by identifying pairs of routine names (functions, procedures) that exhibit high textual similarity but are not identical. It filters for name pairs with a Levenshtein edit distance of exactly one (less than two, but excluding equality). This specific filter targets typographical errors (e.g., calc_tax vs. calc_tux) or inconsistent singular/plural naming (e.g., get_user vs. get_users), while correctly ignoring valid method overloading where names are identical. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
863 Very similar column names This query performs an intra-table analysis to detect potential schema ambiguities. It identifies pairs of columns within the same table that exhibit both high textual similarity and structural equivalence. Specifically, it flags pairs where the names have a Levenshtein edit distance of exactly one and the columns share the same data type or domain. This combination suggests a high probability of typographical errors (e.g., status vs statuss), inconsistent naming (singular vs. plural), or improper denormalization (e.g., item1 vs item2), all of which undermine schema clarity. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
864 Very similar table names This query identifies potential redundancy or ambiguity in the schema by detecting pairs of table names with high textual similarity. It utilizes the Levenshtein distance algorithm to find name pairs that differ by fewer than two characters (i.e., a distance of 0 or 1). This check applies across different types of tables (base tables, foreign tables, derived tables), helping to uncover typographical errors (e.g., users vs user), inconsistent pluralization, or confusingly named entities that violate the principle of distinct and descriptive identifiers. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
865 Views without security barrier Find views that do not have the security barrier option. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
866 Views with unnecessary security invoker Find views with security invoker option that do not have any underlying base table with a security policy. Security invoker option of views is possible starting from PostgreSQL 15. "The main use case (and the one that inspired the feature) is to be able to use views and still check row-level security policies on the underlying tables as the invoker." Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
867 Views with WHERE but without security barrier Find views that do not have the security barrier option but restrict rows in some way. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
868 All clustered indexes Find all tables that rows have been physically sorted based on an index. General system catalog base tables only MIT (opens in new tab) View
869 All database privileges Find the privileges to use the database. c - CONNECT; C - CREATE; T - TEMPORARY. General system catalog base tables only MIT (opens in new tab) View
870 All event triggers Find event triggers, which are not associated to a specific schema object. General system catalog base tables only MIT (opens in new tab) View
871 All exclude constraints Find all exclude constraints. General system catalog base tables only MIT (opens in new tab) View
872 All foreign key constraints Enforce referential integrity in database. Find all referential integrity (foreign key) constraints. General system catalog base tables only MIT (opens in new tab) View
873 All identifying relationships Find all non-identifying relationships where the foreign key (a set of columns) is a subset of a uniqueness constraint (primary key, unique, or exclude constraint). General system catalog base tables only MIT (opens in new tab) View
874 All key constraints This query retrieves a comprehensive list of all PRIMARY KEY and UNIQUE constraints defined on base tables within the database. These constraints are the fundamental mechanisms for enforcing entity integrity and uniqueness. The output provides essential information for schema auditing, documentation generation, and analyzing the data model's key structures. It allows administrators and developers to quickly verify how uniqueness is enforced for each table. General system catalog base tables only MIT (opens in new tab) View
875 All non-identifying relationships Find all non-identifying relationships where the foreign key (a set of columns) is not a subset of any uniqueness constraint (primary key, unique, or exclude constraint). General system catalog base tables only MIT (opens in new tab) View
876 All rules Find user-defined rules for rewriting data manipulation language statements. Rules should be used only for the tasks that cannot be achieved in a declarative manner, i.e., for example, by declaring a constraint. General system catalog base tables only MIT (opens in new tab) View
877 All security policies Find all security policies. General system catalog base tables only MIT (opens in new tab) View
878 All supertables Find all the base tables that serve as supertables in the inheritance hierarchies Sofware measure system catalog base tables only MIT (opens in new tab) View
879 All system-defined TOAST-able types Find system-defined types in case of which the system can use the TOAST technique, i.e., save the value in a compressed form or store it in a automatically-created secondary table, which is hidden from the database user (TOAST table). General system catalog base tables only MIT (opens in new tab) View
880 All uniqueness constraints where nulls are not distinct This query identifies UNIQUE constraints that explicitly use the NULLS NOT DISTINCT clause. Introduced in PostgreSQL 15, this modifier changes standard SQL behavior by treating NULL values as equal, thereby preventing multiple identical rows that contain NULLs. This query is useful for auditing the schema to review where this specific null-handling logic is applied, ensuring it aligns with business rules, or flagging it for environments that require compatibility with older PostgreSQL versions General system catalog base tables only MIT (opens in new tab) View