Created
March 20, 2015 19:06
-
-
Save mkoehrsen/e51ec6f5d167158ef9a4 to your computer and use it in GitHub Desktop.
Postgres -- generate view definition mirroring every table in the public schema
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 'CREATE OR REPLACE VIEW dp_' || table_name || | |
E' AS\nSELECT ' || array_to_string(array_agg(format('%s',column_name)),E',\n ') || | |
E'\nFROM ' || table_name || E';\n' | |
from information_schema.columns | |
where table_schema = 'public' | |
group by table_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment