How do I modify the owner of all tables in a PostgreSQL database?
I tried ALTER TABLE * OWNER TO new_owner
but it doesn't support the asterisk syntax.
postgresql
How do I modify the owner of all tables in a PostgreSQL database?
I tried ALTER TABLE * OWNER TO new_owner
but it doesn't support the asterisk syntax.
Best Answer
You can use the
REASSIGN OWNED
command.Synopsis:
This changes all objects owned by
old_role
to the new role. You don't have to think about what kind of objects that the user has, they will all be changed. Note that it only applies to objects inside a single database. It does not alter the owner of the database itself either.It is available back to at least 8.2. Their online documentation only goes that far back.