Created
February 24, 2020 14:02
-
-
Save afranzi/8ac17873b1ede37a99c907cdd5178d6f to your computer and use it in GitHub Desktop.
Redshift - Retrieve table descriptions
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 | |
t.table_catalog as cluster, | |
t.table_schema as schema_name, | |
t.table_name as table_name, | |
t.table_type as table_type, | |
pt.tableowner as table_owner, | |
pgtd.description as description | |
FROM | |
information_schema.tables as t | |
INNER JOIN pg_catalog.pg_statio_all_tables as st on | |
t.table_schema = st.schemaname | |
and t.table_name = st.relname | |
LEFT JOIN pg_catalog.pg_description pgtd on | |
pgtd.objoid = st.relid | |
and pgtd.objsubid = 0 | |
LEFT JOIN pg_tables pt ON t.table_schema = pt.schemaname AND t.table_name = pt.tablename | |
WHERE table_schema IN ('{{ params.schemas | join("','") }}') | |
ORDER by | |
cluster, | |
schema_name, | |
table_name | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment