Skip to content

Instantly share code, notes, and snippets.

@jbarop
Created April 9, 2014 15:37
Show Gist options
  • Select an option

  • Save jbarop/10284049 to your computer and use it in GitHub Desktop.

Select an option

Save jbarop/10284049 to your computer and use it in GitHub Desktop.
Clone a PostgreSQL schema from command line
pg_dump -d database -n public -f /tmp/public.sql
psql -d database -c 'ALTER SCHEMA public RENAME TO new_schema;'
psql -d database -c 'CREATE SCHEMA public;'
psql -d database -f /tmp/public.sql
rm /tmp/public.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment