PostgreSQL Error 2B000: Dependent Privilege Descriptors
In this article
PostgreSQL error 2B000 (dependent_privilege_descriptors_still_exist) means you tried to drop a role or object that still has privileges granted on other objects. PostgreSQL blocks the drop until those grants are removed. The fix is to find every dependent privilege, revoke or reassign it, then drop the role or object again.
What You'll Need
- Superuser access (or a role with CREATEROLE and the ability to revoke privileges owned by others).
- psql or another SQL client connected to the target database.
- The exact role name or object name that triggered the error.
- Access to every database in the cluster, because privileges can exist outside the current database.
Step-by-Step
- Read the full error message. It usually names the role and the object type (for example, "role \"alice\" cannot be dropped because some objects depend on it"). Note the role or object name and any detail lines listing privileges.
- Connect as a superuser. Run
psql -U postgres -d your_database. If you are not superuser, you may not be able to see or revoke grants owned by other roles. - List privileges granted to the role. In each database, run a query against the system catalogs. For example, to find table privileges:
SELECT grantee, table_schema, table_name, privilege_type FROM information_schema.role_table_grants WHERE grantee = 'alice';Replacealicewith your role. Also checkinformation_schema.role_usage_grantsfor schema and sequence usage, andinformation_schema.role_column_grantsfor column-level grants. - Check other object types. Privileges can exist on schemas, sequences, functions, procedures, types, databases, tablespaces, and foreign servers. Query
pg_class,pg_namespace,pg_proc,pg_type,pg_database, andpg_tablespaceforrelacl,nspacl,proacl,typacl,datacl, andspcaclentries that include the role. A simpler approach is to use\dpin psql to show privileges for tables, views, and sequences, and\dn+for schemas. - Revoke each privilege. For every grant found, run the appropriate
REVOKEstatement. For example:REVOKE SELECT ON TABLE schema.table FROM alice;orREVOKE USAGE ON SCHEMA schema FROM alice;. If the role owns objects, you must reassign ownership first:REASSIGN OWNED BY alice TO new_owner;in each database, thenDROP OWNED BY alice;in each database.DROP OWNEDremoves all privileges and ownership in the current database only, so repeat it in every database. - Repeat across all databases. Connect to each database in the cluster and run the checks and revokes. The error often persists because a grant exists in a database you did not check.
- Drop the role or object again. Once no dependencies remain, run
DROP ROLE alice;or the originalDROPcommand. If it still fails, re-run the catalog queries to catch anything missed.
Common Mistakes
- Only checking the current database. Privileges are per-database; a grant in another database will still block the drop.
- Forgetting ownership. A role that owns objects cannot be dropped until ownership is reassigned or the objects are dropped.
REASSIGN OWNEDhandles this. - Revoking from the wrong grantee. Privileges may be granted to a group role that the target role is a member of. Check role membership with
\duand revoke from the group if needed. - Ignoring default privileges. Default privileges set with
ALTER DEFAULT PRIVILEGEScan create new grants automatically. Checkpg_default_acland revoke or alter them. - Using
DROP OWNEDin only one database. It is scoped to the current database; run it everywhere.
Tips
- Use
\dpand\dn+in psql for a quick visual of grants without writing catalog queries. - Before dropping a role, run
REASSIGN OWNED BY role TO new_owner;thenDROP OWNED BY role;in every database. This is the cleanest way to remove all dependencies. - If you only need to remove a specific privilege, revoke it directly rather than dropping the role.
- Keep a record of grants before revoking, in case you need to restore them.
- Test the drop in a staging environment if possible.
Troubleshooting
If the error persists after revoking visible grants, check for privileges granted to roles that the target role inherits. Use \du to see membership. Also check for grants on large objects, foreign data wrappers, and event triggers. If you cannot find the dependency, query pg_shdepend as superuser: SELECT * FROM pg_shdepend WHERE refobjid = (SELECT oid FROM pg_roles WHERE rolname = 'alice'); This shows shared dependencies across databases. If the role owns objects in a database you cannot access, you may need to connect as a superuser to that database. If you are not superuser, ask your database administrator to perform the revokes or drop.
Frequently Asked Questions
What does error 2B000 mean?
It is PostgreSQL's SQLSTATE for "dependent privilege descriptors still exist." It occurs when you try to drop a role or object that still has privileges granted on other objects.
Can I drop a role without revoking privileges?
No. PostgreSQL requires all dependent privileges and ownership to be removed first. Use REASSIGN OWNED and DROP OWNED in every database.
Does DROP OWNED work across all databases?
No, it only affects the current database. You must run it in each database where the role has objects or privileges.
How do I find all privileges granted to a role?
Query information_schema.role_table_grants, role_usage_grants, and role_column_grants, or use psql commands like \dp and \dn+. Also check pg_shdepend for shared dependencies.
What if I don't have superuser access?
You cannot revoke privileges owned by other roles or see all dependencies. Ask a superuser or the database owner to perform the revokes and drop.
Why does the error mention a specific object?
The error message often includes detail lines naming the object and privilege that depend on the role. Use that information to target your revokes.