Skip to content

Instantly share code, notes, and snippets.

@afranzi
Created February 24, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afranzi/a73d9db819246cab01133687e80ce456 to your computer and use it in GitHub Desktop.
Save afranzi/a73d9db819246cab01133687e80ce456 to your computer and use it in GitHub Desktop.
Redshift - Column description
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