Last active
June 10, 2020 20:19
-
-
Save dinnouti/42fc670017ab3e75681a1fbb375b9165 to your computer and use it in GitHub Desktop.
Redshift - Listing tables, views, columns from database information schema
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_schema | |
, t.table_name | |
, c.column_name | |
, c.data_type | |
, CASE | |
WHEN c.character_maximum_length IS NOT NULL THEN c.character_maximum_length | |
ELSE c.numeric_precision | |
END AS max_length | |
, is_nullable | |
FROM information_schema.tables t | |
JOIN information_schema.columns c ON t.table_schema = c.table_schema AND t.table_name = c.table_name | |
WHERE t.table_schema NOT IN ('information_schema', 'pg_catalog') | |
ORDER BY 1, 2, 3 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment