Skip to content

Instantly share code, notes, and snippets.

@vkostyanetsky
Created March 28, 2026 14:08
Show Gist options
  • Select an option

  • Save vkostyanetsky/a58ff201d2a87a35e70c4c8f4112ad4c to your computer and use it in GitHub Desktop.

Select an option

Save vkostyanetsky/a58ff201d2a87a35e70c4c8f4112ad4c to your computer and use it in GitHub Desktop.
SELECT
string_agg(issues.query_text, ' union all ')
FROM (
SELECT
'select '''
|| table_name
|| ''' as table, '''
|| column_name
|| ''' as column_name, 1 AS counter from '
|| table_name
|| ' where '
|| column_name
|| ' > ''3999-11-01 00:00:00''::timestamp' AS query_text
FROM
information_schema.columns
WHERE
table_catalog = 'acc01'
AND table_schema = 'public'
AND data_type = 'timestamp without time zone'
ORDER BY
table_name,
column_name
) AS issues;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment