GRANT and REVOKE Commands
GRANT
SQL is also used in multi-user environments. The GRANT command is used to permit users access to the database.
The syntax for GRANT command is :
GRANT <PRIVILEGE NAME> | ALL ON <OBJECT> TO <USER | PUBLIC> [WITH GRANT OPTION];
<Privilege name> specifies the action such as INSERT, DELETE, UPDATE, SELECT etc. the user can perform on the <object>. The clause ALL indicates all the privileges
<users> specifies the name to whom the privileges have been granted. To grant the privileges to all the users PUBLIC option is used.
<WITH GRANT OPTIONS> is optional.
A user having privileges can pass on his privileges to another user by using the GRANT command.
REVOKE
The REVOKE command is used to cancel database privileges from users.
The syntax for REVOKE command is:
REVOKE <PRIVILEGE NAME> | ALL ON <OBJECT>FROM <USER | PUBLIC>;
Here in this command REVOKE is the keyword used to deny permissions from any user.
PRIVILEGE NAME indicates the permission like(INSERT, DELETE, UPDATE SELECT etc.) which is to be revoked.
ALL ON OBJECT means form which table or view or from whole database.
Then come FROM clause which indicates form which user the permissions is being revoked.