Created
February 24, 2020 14:03
-
-
Save afranzi/a73d9db819246cab01133687e80ce456 to your computer and use it in GitHub Desktop.
Redshift - Column description
This file contains hidden or 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
SELECT | |
c.table_catalog as cluster, | |
c.table_schema as schema_name, | |
c.table_name as table_name, | |
c.column_name as col_name, | |
c.data_type as col_type , | |
pgcd.description as col_description, | |
ordinal_position as col_sort_order | |
FROM | |
INFORMATION_SCHEMA.COLUMNS c | |
INNER JOIN pg_catalog.pg_statio_all_tables as st on | |
c.table_schema = st.schemaname | |
and c.table_name = st.relname | |
LEFT JOIN pg_catalog.pg_description pgcd on | |
pgcd.objoid = st.relid | |
and pgcd.objsubid = c.ordinal_position | |
WHERE table_schema IN ('{{ params.schemas | join("','") }}') | |
ORDER by | |
cluster, | |
schema_name, | |
table_name, | |
col_sort_order | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment