skip to Main Content

enter image description here

I’m new to Postgres, and I want to delete a role named rp_ts04, but it complains about dependencies. I don’t know how to check for these dependencies.

I’ve checked information_schema but it doesn’t show any relation to rp_ts04.
Can anyone give me a hint in this case?

2

Answers


  1. From DROP ROLE documentation, looks like a role cannot be removed if it is still referenced in somewhere in the database, so you would need to drop all the objects owned by that role using DROP OWNED

    DROP OWNED BY rp_ts04;
    

    or re-asign them to other role using REASSIGN OWNED

    REASSIGN OWNED BY rp_ts04 TO <new role>;
    
    Login or Signup to reply.
  2. DROP OWNED does not exactly sound like it would revoke privileges granted to a role, but it does. As it also drops objects owned by the role, the safe sequence of commands to drop a role is:

    REASSIGN OWNED BY rp_ts04 TO postgres;  -- or some other trusted role
    DROP OWNED BY rp_ts04;
    

    It’s not either-or. Only DROP OWNED removes granted privileges.
    Your error message points to privileges, not ownership. REASSIGN OWNED won’t fix that.

    Run this in all databases of the same cluster where the role might own anything or have been granted privileges. Roles are shared between all databases in the same cluster. Then a final:

    DROP ROLE rp_ts04;
    

    See:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search