Last active
August 29, 2015 14:12
-
-
Save cetver/4fd7b52fd9fe3820c4fe to your computer and use it in GitHub Desktop.
Postgresql: list of columns in select
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
select string_agg('"table name|alias".' || '"' || column_name || '"' || ' AS "alias' || column_name || '"', E',\n') | |
from information_schema.columns | |
where | |
table_schema = 'public' AND | |
table_name = 'table_name' | |
group by table_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment