Dropping a role in PostgreSQL

Dropping a role seems to be a simple thing like:

but it is not… In order to drop a role you need to ensure that there are no objects bound to this role.

How to unbind objects from a role?

Do it for every database!

What is really important while unbinding objects from a role is to DO IT FOR EVERY DATABASE.

Unbinding methods

Brute force version – DROP OWNED

You can use DROP OWNED if you don’t care about the bound objects – see https://www.postgresql.org/docs/current/sql-drop-owned.html

Revoke privileges

You can revoke each privilege one by one – https://www.postgresql.org/docs/current/sql-revoke.html.

Reassign privileges

You can also reassign privileges to another role – https://www.postgresql.org/docs/current/sql-reassign-owned.html.

Pozostaw komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *