REVOKE (Revoke Privileges)
Last updated: 2026-11-04
REVOKE (Revoke Privileges)
REVOKE takes back privileges that were granted earlier, mirroring GRANT. It can withdraw a specific privilege from a role on an object, or withdraw only the WITH GRANT OPTION — keeping the access but stopping it from being passed on.
| Kind | command |
|---|---|
| Example Language | SQL |
📝 Syntax
REVOKE [GRANT OPTION FOR] { <privilege> | ALL [PRIVILEGES] } ON [TABLE] <table> [, ...]
FROM <role> [, ...]
[CASCADE | RESTRICT]
⚙️ Parameters
| GRANT OPTION FOR | Withdraws only the ability to re-grant |
|---|---|
| ON <object> | The table, sequence, or schema the privilege applies to |
| FROM <role> | The role losing the privilege |
| PUBLIC | The implicit member that stands for every user |
Returns:No return value. The privilege stops applying as soon as the statement succeeds.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
DROP TABLE
CREATE TABLE
INSERT 0 2
DO
GRANT
REVOKE
grantee | privilege_type
--------------+---------------
report_reader | SELECT
📌 Key Points
- REVOKE only withdraws privileges that were explicitly granted; those coming from PUBLIC or role membership need separate handling.
- Use REVOKE ... FROM PUBLIC to take back privileges every user holds by default.
- REVOKE GRANT OPTION FOR ... keeps the privilege but removes the right to pass it on.
- The object owner always retains full privileges; REVOKE cannot take them away.
- Re-check with information_schema.role_table_grants afterwards to confirm no other grant path remains.
- REVOKE ... CASCADE also withdraws privileges that were granted in reliance on this one.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QCan the user still reach the data after a REVOKE?
APossibly: the privilege may also arrive via PUBLIC or via another role the user belongs to. Walk every grant path in information_schema.role_table_grants and revoke them one by one.
QHow do I revoke an inherited privilege?
AInherited privileges cannot be revoked directly. Revoke at the source — drop the privilege from the granting role, or remove the user from that role.