Last active
August 24, 2022 14:57
-
-
Save martinov/fbe1a29792bf1482cd859dc51631e6d5 to your computer and use it in GitHub Desktop.
List all JSON and JSONB fields in given Postgres DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Source: https://dataedo.com/kb/query/postgresql/find-all-json-columns | |
select col.table_schema, | |
col.table_name, | |
col.ordinal_position as column_id, | |
col.column_name, | |
col.data_type | |
from information_schema.columns col | |
join information_schema.tables tab on tab.table_schema = col.table_schema | |
and tab.table_name = col.table_name | |
and tab.table_type = 'BASE TABLE' | |
where col.table_schema not in ('information_schema', 'pg_catalog', 'graphile_worker') | |
and col.data_type in ('json', 'jsonb') | |
order by col.table_schema, | |
col.table_name, | |
col.ordinal_position; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment