Created
August 30, 2016 05:00
-
-
Save robertpostill/4336d6d34a212155b46dd40ab249422f to your computer and use it in GitHub Desktop.
COPY STATEMENT
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
COPY (SELECT string_agg(quote_ident(column_name) || | |
CASE udt_name | |
WHEN 'timestamp' THEN '::timestamp(0)' | |
WHEN 'timestamptz' THEN '::timestamptz(0)' | |
WHEN 'text' THEN '::varchar(6000)' | |
ELSE '' | |
END, | |
',' | |
) | |
FROM information_schema.columns | |
WHERE | |
table_schema = '$schema' AND | |
table_name = '$TBL') | |
TO STDOUT WITH DELIMITER AS '|' CSV HEADER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment