I want to change owner of all tables in one particular database using
REASSIGN OWNED BY postgres TO myuser
but it shows:
ERROR: cannot reassign ownership of objects owned by role postgres because they are required by the database system
I think it's because there are more databases in this system, but I want to reassign owners only in one specified databse (database1).
Is there a way?
To alter the owner, you must own the database and also be a direct or indirect member of the new owning role, and you must have the CREATEDB privilege. (Note that superusers have all these privileges automatically.) The fourth form changes the default tablespace of the database.
You must own the table to use ALTER TABLE. To change the schema of a table, you must also have CREATE privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have CREATE privilege on the table's schema.
Because the postgres
user owns system catalogs, you cannot reassign all objects owned by postgres
. You will have to sort out this situation by hand in this case. In the future, avoid using postgres
for non-administrative tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With