REVOKE failed because the specified privilege had not been granted to the role.
PostgreSQL Error 1006 privilege_not_revoked appears when a REVOKE command targets a privilege the role never had. Verify existing grants with psql's \dp or pg_catalog queries, then remove or correct the REVOKE statement to match actual privileges.
PostgreSQL Error 1006
PostgreSQL raises error 1006 privilege_not_revoked when you issue a REVOKE statement for a privilege the specified role does not currently hold. The server cannot remove what is not there, so execution stops.<\/p>
The error usually surfaces during automated permission clean-ups, migration scripts, or manual privilege audits. Fixing it quickly keeps deployment pipelines green and permissions accurate.<\/p>
Most cases trace back to mismatched GRANT and REVOKE statements.
Scripts assume a previous GRANT ran, but it was skipped or executed on a different environment. The subsequent REVOKE therefore fails.<\/p>
A second trigger is object recreation. Dropping and re-creating a table clears its ACL. Any later REVOKE aimed at the old ACL rows will fire the 1006 error.<\/p>
Start by confirming the role’s current privileges with \dp or a pg_catalog query.
If the privilege is missing, remove the REVOKE line or guard it with IF EXISTS logic available since PostgreSQL 15.<\/p>
When the privilege should exist, GRANT it first and then REVOKE, or adjust the migration order so the REVOKE runs only after the GRANT in every environment.<\/p>
Continuous integration scripts that run GRANT commands only on new databases often miss staging and prod drifts.
Add explicit GRANT checks before each REVOKE to stop false alarms.<\/p>
Infrastructure-as-code tools may drop and recreate tables. Tie REVOKE statements to change detection hooks so they execute only on persistent objects.<\/p>
Audit privileges regularly with automated reports stored in version control.
Differences highlight drift before REVOKE scripts fail.<\/p>
Use conditional syntax in PostgreSQL 15+: REVOKE SELECT ON TABLE my_table FROM role IF EXISTS;<\/code> to silence harmless revocations while still catching real issues on older versions.<\/p>
Related Errors and Solutions<\/h3>
Error privilege_not_granted fires on failed GRANT statements. Its fix path mirrors 1006: verify existing ACLs first.<\/p>
Error undefined_table occurs when REVOKE targets a table that no longer exists. Ensure object lifecycles align with permission scripts.<\/p>.