Skip to content

Instantly share code, notes, and snippets.

@thm1118
Last active June 8, 2018 19:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thm1118/9320610 to your computer and use it in GitHub Desktop.
Save thm1118/9320610 to your computer and use it in GitHub Desktop.
bulk alter role of postgreSQL's database or table or view .etc
REASSIGN OWNED BY old_role [, ...] TO new_role
@thm1118
Copy link
Author

thm1118 commented Mar 3, 2014

more complex shell script + sql :
https://gist.github.com/gingerlime/2482969

@NotSqrt
Copy link

NotSqrt commented Jun 20, 2014

👍

@PhilinTv
Copy link

You can't use this if:

  • your db owned by postgres
  • you want to change onwer for one db only.

But It's very helpful to replace one user by another for whole db.

@RafaAguilar
Copy link

If your are applying it to multiple database which has multiple schemas with multiple objects, where all the named could have different owners :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment