Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --1. Using psql, paste query
- --2. Copy SQL result
- --3. Paste new SQL, execute to create view
- SELECT 'CREATE OR REPLACE VIEW some_schema.some_view AS SELECT ' ||
- (SELECT STRING_AGG(column_name || ' AS some_table_' || column_name, ', ')
- FROM information_schema.columns
- WHERE table_name = 'some_table'
- GROUP BY table_name) ||
- ' FROM some_schema.some_table;';
Advertisement
Add Comment
Please, Sign In to add comment