GRANT assigns privileges on database objects or roles to users, roles, or PUBLIC in Oracle.
The GRANT statement lets DBAs and developers control who can SELECT, INSERT, UPDATE, DELETE, or execute procedures. Fine-grained rights reduce security risks and audit noise.
GRANT follows a simple pattern: list privileges, reference the object, identify grantees, and optionally add WITH GRANT OPTION so recipients can pass rights on.
Typical rights include SELECT on Products for pricing APIs, INSERT on Orders for checkout services, and UPDATE on Stock in Products after shipping workflows.
Use a comma-separated list: GRANT SELECT, INSERT ON Orders TO sales_app; combines privileges in one atomic statement for easier review.
Append WITH GRANT OPTION. Example: GRANT SELECT ON Customers TO analyst WITH GRANT OPTION; lets analyst delegate read access to teammates.
Create a role, grant object rights to it, then grant the role to users. This prevents repetitive object grants and eases user turnover.
Use REVOKE followed by the same privilege list. REVOKE SELECT ON Customers FROM contractor; removes read access instantly.
Grant least privilege, prefer roles over direct grants, document exceptions, and schedule periodic audits. Always test in staging first.
Yes. GRANT UPDATE(quantity) ON OrderItems TO inventory_bot; restricts changes to the quantity column only.
If A grants WITH GRANT OPTION to B, and B grants to C, revoking from B also removes C’s privileges.