Last active
January 8, 2018 16:56
-
-
Save rodo/e2fff23da180390fbff0d34dbc72c460 to your computer and use it in GitHub Desktop.
Manage postgresql template
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
| # our template database will be called template2 | |
| # as user foobar | |
| $ createdb template2 | |
| $ psql -d template2 -c 'create table test (id integer)' | |
| $ psql -d template2 -c '\d' # you see that the table is owned by foobar | |
| # create a new db based on the template | |
| $ createdb new -T template2 -O newuser | |
| $ psql -d new -c 'REASSIGN OWNED BY foobar TO newuser' | |
| $ psql -d new -c '\d' # the table test is owned by newuser | |
| $ psql -l # show that the owner of template2 is now newuser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment