The list of all the queries

All domains

Query goal: Find all domains.
Query type: General (Overview of some aspect of the database.)
Query license: MIT License
Data source: INFORMATION_SCHEMA only
SQL query: Click on query to copy it

WITH dom AS (SELECT domain_schema, 
domain_name, 
CASE WHEN data_type ILIKE 'character%' AND character_maximum_length IS NOT NULL THEN data_type || '(' || character_maximum_length::text || ')'
WHEN data_type ILIKE 'timestamp%' AND datetime_precision IS NOT NULL THEN data_type || '(' || datetime_precision || ')'
WHEN data_type ILIKE 'numeric%' AND numeric_precision IS NOT NULL THEN data_type || '(' || numeric_precision::text || ',' ||coalesce(numeric_scale,0)::text || ')'
WHEN data_type ILIKE 'interval%' AND interval_type IS NOT NULL THEN data_type || '(' || interval_type::text || ')'
WHEN data_type='USER-DEFINED' THEN udt_schema || '.' || udt_name 
ELSE data_type END AS data_type,
domain_default,
collation_schema,
collation_name
FROM INFORMATION_SCHEMA.domains
WHERE domain_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL))
SELECT domain_schema, domain_name, data_type, domain_default,
string_agg('Name: ' || dc.constraint_name || 
'<br>check: ' || cc.check_clause ||
'<br>is deferrable: ' || dc.is_deferrable ||
'<br>initially deferred: ' || dc.initially_deferred, ',<p>' ORDER BY dc.constraint_name) AS constraints,
collation_schema, collation_name
FROM dom LEFT JOIN INFORMATION_SCHEMA.domain_constraints AS dc USING (domain_schema, domain_name)
LEFT JOIN INFORMATION_SCHEMA.check_constraints AS cc ON dc.domain_schema=cc.constraint_schema AND dc.constraint_name=cc.constraint_name AND check_clause LIKE '%VALUE%'
GROUP BY domain_schema, domain_name, data_type, domain_default, collation_schema, collation_name
ORDER BY domain_schema, domain_name;

Collections where the query belongs to

Collection nameCollection description
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 where the query belongs to

Category nameCategory description
DomainsQueries of this category provide information about reusable specifications of column properties.

The list of all the queries