Skip to content

Instantly share code, notes, and snippets.

@jms
Forked from juike/restore.sql
Created June 5, 2018 20:47
Show Gist options
  • Save jms/9c2ae800e036b57c93e5adafb5de9554 to your computer and use it in GitHub Desktop.
Save jms/9c2ae800e036b57c93e5adafb5de9554 to your computer and use it in GitHub Desktop.

Revisions

  1. @juike juike created this gist Nov 21, 2014.
    8 changes: 8 additions & 0 deletions restore.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0';
    \c template0
    UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
    DROP DATABASE template1;
    CREATE DATABASE template1 WITH TEMPLATE = 'template0';
    \c template1
    UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
    UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template0';