The GRANT statement gives users authorization to perform one or more operations on a table.
You must be authorized to insert, update, delete, alter, or select rows in a table you do not own. Authorization must be granted by the creator of the table or by someone to whom the creator granted such authorization.
The syntax of the GRANT statement is:
GRANT operation-list ON tablename TO user-list WITH GRANT OPTION
- One or more of the following privileges that are separated by
commas: ALTER, DELETE, INSERT, SELECT, UPDATE (column-list).
ALL grants authorization to perform all operations for which the grantor is authorized.
- Names a table or view for which the authorization is granted.
- Lists each user ID with commas between them. PUBLIC can be specified in place of user-list to grant authorization to all users.
- WITH GRANT OPTION clause
- Authorizes another user to use the GRANT keyword to grant the same privileges to other users. This clause is optional.
The following statement grants authorization to all other users to display the PERS table or issue SELECT statements that select data from it:
GRANT SELECT ON PERS TO PUBLIC
The following statement grants authorization to user HSAM4419 to insert and delete rows in PERS:
GRANT INSERT, DELETE ON PERS TO HSAM4419
The following statement grants authorization to SMITH to update PERS and to grant this authorization to other users:
GRANT UPDATE ON PERS TO SMITH WITH GRANT OPTION