Perhaps in some cases the default value is not needed and should be dropped.
Data Source
INFORMATION_SCHEMA only
SQL Query
WITH cols AS (SELECT c.table_schema, c.table_name, c.column_name, coalesce(c.column_default, domain_default) AS default_value, c.ordinal_position
FROM information_schema.columns AS c LEFT JOIN information_schema.domains d USING (domain_schema, domain_name)
INNER JOIN INFORMATION_SCHEMA.tables AS t USING (table_schema, table_name)
WHERE c.table_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
AND t.table_type='BASE TABLE')
SELECT table_schema, table_name, Count(*) AS nr_of_columns, string_agg(column_name || '.' || default_value, '; ' ORDER BY ordinal_position) AS defaults
FROM cols
GROUP BY table_schema, table_name
HAVING Count(*)=Count(*) FILTER (WHERE default_value IS NOT NULL)
ORDER BY table_schema, table_name;
Collections
This query belongs to the following collections:
Name
Description
Find problems about base tables
A selection of queries that return information about the data types, field sizes, default values as well as general structure of base tables. Contains all the types of queries - problem detection, software measure, and general overview
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
Categories
This query is classified under the following categories:
Name
Description
Comfortability of data management
Queries of this category provide information about the means that have been used to make the use or management of database more comfortable and thus, more efficient.
Default value
Queries of this catergory provide information about the use of default values.