20

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?

pawel
  • 5,976
  • 15
  • 46
  • 68
  • possible duplicate of [Modify OWNER on all tables simultaneously in PostgreSQL](http://stackoverflow.com/questions/1348126/modify-owner-on-all-tables-simultaneously-in-postgresql) – Daniel Vérité Jun 06 '13 at 13:18
  • Possible duplicate of [How to change owner of PostgreSql database?](http://stackoverflow.com/questions/4313323/how-to-change-owner-of-postgresql-database) – Flimm Mar 16 '17 at 17:53

1 Answers1

16

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.

Peter Eisentraut
  • 35,221
  • 12
  • 85
  • 90