| Lesson 8 | Revoking system privileges |
| Objective | Revoke privileges and roles from Oracle users safely and correctly. |
REVOKE statement. Revokes take effect immediately—even if the user is currently connected, so commands that rely on a removed privilege will start failing at once.
REVOKE CREATE USER, CREATE SESSION FROM jeff;
REVOKE RESOURCE FROM app_runtime;
REVOKE EXECUTE ANY PROCEDURE FROM reporting_svc;
REVOKE CONNECT FROM PUBLIC;
Revoke system privileges and/or roles
REVOKE { system_privilege | role }
[, { system_privilege | role } ]...
FROM { user | role | PUBLIC }
[, { user | role | PUBLIC } ]...
[ CONTAINER = { CURRENT | ALL } ] -- CDB environments (common users/roles)
Grant refresher (for comparison)
GRANT { system_privilege | role }
[, { system_privilege | role } ]...
TO { user | role | PUBLIC }
[, { user | role | PUBLIC } ]...
[ WITH ADMIN OPTION ]
[ CONTAINER = { CURRENT | ALL } ]
CDB$ROOT and use CONTAINER=ALL when appropriate.CONTAINER=CURRENT.Revoke a risky system privilege
REVOKE DROP ANY TABLE FROM dev_tooling;
Remove a role you no longer want a user to have
REVOKE DBA FROM temp_admin;
Stop general access granted through PUBLIC
REVOKE CREATE SESSION FROM PUBLIC;
DBA_TAB_PRIVS, DBA_SYS_PRIVS, DBA_ROLE_PRIVS.ALTER SYSTEM, DROP ANY TABLE).Revoking everything does not remove the account. To delete a user and deal with owned objects:
DROP USER username CASCADE;
CASCADE, the drop fails if the user still owns objects.CASCADE, Oracle drops the user, their objects, and dependent constraints; views/procedures that reference those objects become invalid.