Created
June 2, 2014 09:46
-
-
Save marinbek/c6357619ead29c25144a to your computer and use it in GitHub Desktop.
Import all tables from one schema to another schema - Redshift
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 'drop table '||n.nspname ||'.'|| c.relname||' CASCADE;' as "Name" | |
FROM pg_catalog.pg_class c | |
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace | |
WHERE c.relkind IN ('r','v','S','') | |
AND n.nspname = 'destination_schema'; | |
SELECT 'create table '||n.nspname ||'.'|| c.relname||' as select * from source_schema.' || c.relname||';' as "Name" | |
FROM pg_catalog.pg_class c | |
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace | |
WHERE c.relkind IN ('r','v','S','') | |
AND n.nspname = 'destination_schema'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment