Re: Drop role cascade ?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: David Gauthier <dfgpostgres(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Drop role cascade ?
Date: 2022-11-17 23:16:24
Message-ID: 5eabfe58-0dfe-5438-fa3d-fc840c709bdd@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/17/22 15:07, David Gauthier wrote:
> psql (11.5, server 11.3) on linux
>
> Someone who had privileges in a lot of tables/schemas/DBs left the
> company.  I want to drop that role but "rop role xxx" won't let me
> because...  "xxx cannot be dropped because some objects depend on it".
>
> Is there a way to just get rid of this role without revoking xxx in all
> the individual DB objects he has privs too?  Something like "drop role
> xxx cascade" ?

1) You might want to confirm that removing that role is not going to
leave you a bind where the objects do not have the necessary privileges
to complete their tasks.

2) From here :

https://www.postgresql.org/docs/current/sql-droprole.html

"A role cannot be removed if it is still referenced in any database of
the cluster; an error will be raised if so. Before dropping the role,
you must drop all the objects it owns (or reassign their ownership) and
revoke any privileges the role has been granted on other objects. The
REASSIGN OWNED and DROP OWNED commands can be useful for this purpose;
see Section 22.4 for more discussion."

So you should take a look at:

https://www.postgresql.org/docs/current/sql-reassign-owned.html

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-11-17 23:16:56 Re: Drop role cascade ?
Previous Message David Gauthier 2022-11-17 23:07:50 Drop role cascade ?