REVOKE removes previously granted privileges from roles or the public group, tightening access to database objects.
Revoking permissions is essential when a user’s job changes, when sensitive data moves tables, or when least-privilege policies are enforced. It guarantees that only the right roles can query, insert, or alter data.
Use REVOKE privilege[, ...] ON object FROM role[, ...] [CASCADE | RESTRICT].Privileges include SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, and ALL.
Run REVOKE SELECT ON TABLE Customers FROM analytics_reader;.The role analytics_reader can no longer read the Customers table.
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM developer_temp; removes every right that developer_temp once had in the public schema.
ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE SELECT ON TABLES FROM data_viewer; stops automatic SELECT rights on new tables.
Query information_schema.role_table_grants or run \dp in psql to list grants and confirm that revocations succeeded.
Create functional roles, grant only what is needed, test in staging, and script revocations alongside grants for reproducibility.
.
No. REVOKE is idempotent; it silently succeeds even when the target role lacks the privilege.
No. Existing sessions keep their current transaction rights, but new commands requiring the revoked privilege will fail.
Simply issue the corresponding GRANT statement to restore the privilege.