The list of all the queries

Inconsistency between the type and the default value of a column (date and timestamp values)

Query goal: Find table columns with timestamp/date types that data type and dynamically found default value have a different type.
Notes about the query: The query finds default values that are associated directly with a base table column as well as default values that are specified through a domain. The query does not find default values of domains that are not associated with any table.
Query type: Problem detection (Each row in the result could represent a flaw in the design)
Query reliability: Medium (Medium number of false-positive results)
Query license: MIT License
Fixing suggestion: Change the default value or the data type of the column.
Data source: INFORMATION_SCHEMA only
SQL query: Click on query to copy it

WITH temp_col AS (SELECT c.table_schema, t.table_type, c.table_name, c.column_name, c.ordinal_position, c.data_type, coalesce(column_default, domain_default) AS def
FROM INFORMATION_SCHEMA.columns AS c LEFT JOIN INFORMATION_SCHEMA.domains AS d USING (domain_schema, domain_name)
INNER JOIN INFORMATION_SCHEMA.tables AS t USING (table_schema, table_name)
WHERE c.data_type IN ('date', 'timestamp without time zone', 'timestamp with time zone') 
AND 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))
SELECT table_schema, table_type, table_name, column_name, data_type, def
FROM temp_col
WHERE (def ~* '^LOCALTIMESTAMP' AND data_type<>'timestamp without time zone') 
OR ((def ~* '^(CURRENT_TIMESTAMP|CLOCK_TIMESTAMP|STATEMENT_TIMESTAMP|TRANSACTION_TIMESTAMP)' OR def='now()') AND data_type<>'timestamp with time zone') 
OR (def='CURRENT_DATE' AND data_type<>'date')
ORDER BY table_schema, table_name, ordinal_position;

Collections where the query belongs to

Collection nameCollection description
Find problems about base tablesA 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 automaticallyQueries, 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 where the query belongs to

Category nameCategory description
Comfortability of data managementQueries 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.
Data typesQueries of this category provide information about the data types and their usage.
Default valueQueries of this catergory provide information about the use of default values.
InconsistenciesQueries of this catergory provide information about inconsistencies of solving the same problem in different places.
System-defined functionsQueries of this category provide information about the use of system-defined functions.
Temporal dataQueries of this category provide information about temporal (time-related) data that is kept in the database.
Validity and completenessQueries 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).

Reference materials for further reading

Reference
https://www.postgresql.org/docs/current/functions-datetime.html

The list of all the queries