Replace default value that is a textual value (has aposthrophes) with a default value that has no apostrophes, i.e., is not a representation of a textual value.
Data Source
INFORMATION_SCHEMA only
SQL Query
SELECT A.table_schema, T.table_type, A.table_name , A.column_name, A.data_type, d.domain_default, a.column_default
FROM information_schema.columns A INNER JOIN information_schema.tables T USING (table_schema, table_name)
INNER JOIN information_schema.schemata S ON A.table_schema=S.schema_name
LEFT JOIN information_schema.domains D USING (domain_schema, domain_name)
WHERE (A.table_schema = 'public'
OR S.schema_owner<>'postgres')
AND A.data_type IN ('smallint','integer','bigint','double precision','real','numeric') AND
((D.domain_default LIKE '%::'|| A.data_type AND D.domain_default~'['']')
OR (A.column_default LIKE '%::'|| A.data_type AND A.column_default~'['']'))
ORDER BY table_type, table_schema, table_name, column_name;
Collections
This query belongs to the following collections:
Name
Description
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 database evolution
Queries of this category provide information about the means that influence database evolution.
Data types
Queries of this category provide information about the data types and their usage.
Default value
Queries of this catergory provide information about the use of default values.
Performance
Queries of this category provide information about indexes in a database.
Validity and completeness
Queries of this category provide information about whether database design represents the world (domain) correctly (validity) and whether database design captures all the information about the world (domain) that is correct and relevant (completeness).