Best way to change the owner of a PostgreSQL database and their tables?
postgresql
Solution
According to the manual:
Because REASSIGN OWNED does not affect objects within other databases, it is usually necessary to execute this command in each database
which would seem to meet your requirements, although it also says the command would affect table spaces (which are not specific to the current database).
The second SO answer you linked applies to the special case of the postgres user, which owns the system catalogs. You cannot change the ownership of these.
Problem
I am trying to change the owner of a PostgreSQL database (version > 8.2) and its tables. I read this solution: Modify OWNER on all tables simultaneously in PostgreSQL But is this the best way to do it (for recent versions of PostgreSQL)?. It seems that there is a function REASSIGN OWNED which is better, but this one changes every database owned by the old_role, doesn't it? I only want it for one database. Like this post: REASSIGN OWNED BY for 1 specified database I am not going to change the owner postgres, which is the best way nowadays? Thank you in advance