sql / intermediate
Snippet
Assigning Role-Based Object Access Rights with GRANT
The GRANT statement assigns specific database permissions on target database objects to database users or roles. Restricting access to only necessary operations (like SELECT and INSERT) aligns with the principle of least privilege.
snippet.sql
sql
1
2
3
GRANT SELECT, INSERTON TABLE invoicesTO auditor_role;
Breakdown
1
GRANT SELECT, INSERT
Specifies the privilege types to grant (read data and insert new rows).
2
ON TABLE invoices
Identifies the target database table object ('invoices').
3
TO auditor_role;
Designates the receiving database user or role entity.