Created
March 24, 2017 20:24
-
-
Save rjdp/6ae9a0c204ee10aba7d2bd111ccc8495 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# dump specific postgres schemas from database `mydb` | |
pg_dump -U postgres -nschema1 -npublic -npg_catalog -npg_toast -ninformation_schema -Fc mydb > mydb.dump | |
# after restoring above data move the table from the original schema to public schema | |
DO | |
$$ | |
DECLARE | |
row record; | |
BEGIN | |
FOR row IN SELECT tablename FROM pg_tables WHERE schemaname = 'schema_primedomaincom' | |
LOOP | |
BEGIN | |
EXECUTE 'ALTER TABLE schema_primedomaincom.' || quote_ident(row.tablename) || ' SET SCHEMA public;'; | |
EXCEPTION | |
WHEN others THEN CONTINUE; | |
END; | |
END LOOP; | |
END; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment