Created
March 31, 2016 14:56
-
-
Save mkjasinski/6e67480ce11ca375552173e8001f6b5f to your computer and use it in GitHub Desktop.
[PostgreSQL] change owner
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
#!/bin/bash | |
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" [db-name]` ; do | |
psql -c "alter table $tbl owner to \"[db-user]\"" [db-name] ; | |
done | |
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" [db-name]` ; do | |
psql -c "alter table \"$tbl\" owner to \"[db-user]\"" [db-name] ; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment