Goal Find domains that specify a default values and columns that are defined based on the domain. Make sure that there are no unsuitable default values.
Type General (Overview of some aspect of the database.)
License MIT (opens in new tab)
Data Source INFORMATION_SCHEMA only
SQL Query
SELECT domain_schema, domain_name , domain_default, string_agg(table_schema || '.' || table_name || '.' || column_name, ';<br>' ORDER BY table_schema, table_name) AS columns
FROM information_schema.columns c
RIGHT JOIN information_schema.domains d USING (domain_schema, domain_name)
INNER JOIN information_schema.schemata s
ON d.domain_schema=s.schema_name
WHERE  d.domain_default IS NOT NULL
AND (d.domain_schema = 'public'
OR s.schema_owner<>'postgres')
GROUP BY domain_schema, domain_name , domain_default
ORDER BY domain_schema, domain_name;

Collections

This query belongs to the following collections:

Find problems by overview

Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .

NameDescription
Find problems by overviewQueries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .

Categories

This query is classified under the following categories:

Default value

Queries of this catergory provide information about the use of default values.

Domains

Queries of this category provide information about reusable specifications of column properties.

NameDescription
Default valueQueries of this catergory provide information about the use of default values.
DomainsQueries of this category provide information about reusable specifications of column properties.