Granting Privileges to a Stored Procedure or Trigger
Go Up to Granting Privileges
A stored procedure, view, or trigger sometimes needs privileges to access a table or view that has a different owner. To grant privileges to a stored procedure, put the
PROCEDURE keyword before the procedure name. Similarly, to grant privileges to a trigger or view, put the
VIEW keyword before the object name.
- Important: When a trigger, stored procedure or view needs to access a table or view, it is sufficient for either the accessing object or the user who is executing it to have the necessary permissions.
The following statement grants the
INSERT privilege for the
ACCOUNTS table to the procedure,
GRANT INSERT ON ACCOUNTS TO PROCEDURE MONEY_TRANSFER;
- Tip: As a security measure, privileges to tables can be granted to a procedure instead of to individual users. If a user has
EXECUTEprivilege on a procedure that accesses a table, then the user does not need privileges to the table.