Explain GRANT commands and REVOKE commands with their syntax.
GRANT – is used to assign or grant privileges to users.
Syntax:GRANT <privilege> <user>
Example:GRANT CREATE INDEX TO John
REVOKE – is used to revoke or withdraw any privilege.
REVOKE CREATE INDEX FROM John;
Explain GRANT commands and REVOKE commands with their syntax.
GRANT command is used to provide previleges on the data objects such as tables, views, procedures etc, to the users.
Syntax :GRANT privilege_name ON object_name TO {user_name | PUBLIC | role_name }
[WITH GRANT OPTION]
-privilege_name is the name of the access right that is granted.
-object_name can be a table, view, stored procedure and sequence
-user_name is the user account name , to whom the privilege is granted
-PUBLIC is to grant the privileges to all the users
-role_name is a collective name for a group of privileges
-WITH GRANT OPTION allows the users to grant the privileges to other users.
Example: To grant SELECT privilege on employee table to user Fedrick:
GRANT SELECT ON EMPLOYEE TO FEDRICK.
REVOKE: REVOKE command is used to remove the granted privileges given to the users.
Syntax :REVOKE privilege_name ON object_name FROM {user_name | PUBLIC | role_name}
Example: To revoke the select privilege on employee table:
REVOKE SELECT ON EMPLOYEE FROM FEDRICK