Filter Queries

Found 1096 queries.

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

#21. All foreign tables

INFORMATION_SCHEMA only

Find all foreign tables.

General License: MIT (opens in new tab)

#22. All gin indexes

INFORMATION_SCHEMA+system catalog base tables

Find indexes with less common access methods. Gin indexes are, for instance, used to speed up PostgreSQL's built in full text search.

General License: MIT (opens in new tab)

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

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

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

#26. All non-unique indexes

INFORMATION_SCHEMA+system catalog base tables

Find secondary indexes that have been created in the database.

General License: MIT (opens in new tab)

#27. All parameters with DEFAULT values

INFORMATION_SCHEMA+system catalog base tables

Find parameters of user-defined routines that have a default value.

General License: MIT (opens in new tab)

#28. All partial indexes

INFORMATION_SCHEMA+system catalog base tables

Find indexes to a subset of table rows.

General License: MIT (opens in new tab)

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

#30. All security policies

system catalog base tables only

Find all security policies.

General License: MIT (opens in new tab)

#31. All sequence generators

INFORMATION_SCHEMA+system catalog base tables

Find all sequence generators.

General License: MIT (opens in new tab)

#32. All short cycles (tables)

INFORMATION_SCHEMA+system catalog base tables

Find pairs of tables that have both a foreign key that references to the other table. Such cycles can involve more than two tables but the query detects only cycles with two tables.

General License: MIT (opens in new tab)

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

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

#35. All table CHECK constraints that cover at leat one column

INFORMATION_SCHEMA only

Find all CHECK constraints (except NOT NULL) that are associated with a base table or a foreign table column. 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)

#36. All table functions

INFORMATION_SCHEMA+system catalog base tables

Find all functions that return a set of rows.

General License: MIT (opens in new tab)

#37. All the non-primary key columns are optional

INFORMATION_SCHEMA only

Find base tables where all he non-primary key columns are optional. Avoid too many optional columns. You have to be extra careful with NULLs in case of formulating search conditions of data manipulation statements.

Problem detection License: MIT (opens in new tab)

#38. All unique keys have at least one optional column

INFORMATION_SCHEMA+system catalog base tables

This query identifies base tables where every unique key (whether enforced by a UNIQUE constraint or a unique index) includes at least one optional (nullable) column. This is a critical design flaw because it allows rows to exist where the identifying values are partially or entirely missing. Furthermore, because standard SQL treats NULL as an unknown state rather than a distinct value, two NULLs are not considered equal. As a result, a standard UNIQUE constraint fails to prevent the insertion of multiple identical rows if they contain NULL values. The query exempts constraints that explicitly use the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULLs as equal.

Problem detection License: MIT (opens in new tab)

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

#40. All user-defined TOAST-able types

system catalog base tables only

Find user-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)
# 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
21 All foreign tables Find all foreign tables. General INFORMATION_SCHEMA only MIT (opens in new tab) View
22 All gin indexes Find indexes with less common access methods. Gin indexes are, for instance, used to speed up PostgreSQL's built in full text search. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
23 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
24 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
25 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
26 All non-unique indexes Find secondary indexes that have been created in the database. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
27 All parameters with DEFAULT values Find parameters of user-defined routines that have a default value. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
28 All partial indexes Find indexes to a subset of table rows. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
29 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
30 All security policies Find all security policies. General system catalog base tables only MIT (opens in new tab) View
31 All sequence generators Find all sequence generators. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
32 All short cycles (tables) Find pairs of tables that have both a foreign key that references to the other table. Such cycles can involve more than two tables but the query detects only cycles with two tables. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
33 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
34 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
35 All table CHECK constraints that cover at leat one column Find all CHECK constraints (except NOT NULL) that are associated with a base table or a foreign table column. 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
36 All table functions Find all functions that return a set of rows. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
37 All the non-primary key columns are optional Find base tables where all he non-primary key columns are optional. Avoid too many optional columns. You have to be extra careful with NULLs in case of formulating search conditions of data manipulation statements. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View
38 All unique keys have at least one optional column This query identifies base tables where every unique key (whether enforced by a UNIQUE constraint or a unique index) includes at least one optional (nullable) column. This is a critical design flaw because it allows rows to exist where the identifying values are partially or entirely missing. Furthermore, because standard SQL treats NULL as an unknown state rather than a distinct value, two NULLs are not considered equal. As a result, a standard UNIQUE constraint fails to prevent the insertion of multiple identical rows if they contain NULL values. The query exempts constraints that explicitly use the UNIQUE NULLS NOT DISTINCT clause, which safely treats NULLs as equal. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
39 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
40 All user-defined TOAST-able types Find user-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