In: Computer Science
Q1)Write the syntax SQL DCL “GRANT” and and REVOKE Commands?
Q2 ) Write SQL DCL Commands?
i. To give the user Ahmad permission to view and modify records in the table Employee.
ii. To revoke the permission to view and modify the records in the table Employee.
Answer:
Q1) The SQL Data controlling language(DCL) has two commands namely GRANT and REVOKE.
GRANT Command: GRANT Command is used to give privileges(permissions) to the users.
The syntax for GRANT command is--
GRANT privilege_name on objectname to user;
Here,privilege names are SELECT,UPDATE,DELETE,INSERT,ALTER,ALL
objectname is table name.
user is the name of the user to whom we grant privileges.
REVOKE Command: REVOKE Command is used to remove the privileges granted to user on database objects.
The syntax for REVOKE command is--
REVOKE privilege_name on objectname from user;
Here,privilege names are SELECT,UPDATE,DELETE,INSERT,ALTER,ALL
objectname is table name.
user is the name of the user whose privileges are removing.
Q2)
i) To give the user Ahmad permission to view and modify records in the table Employee.
The DCL Command is--
GRANT SELECT,UPDATE on Employee to Ahmad.
Explanation: Firstly to give the permissions to user,We have to use GRANT command.The privileges are SELECT because to view the records and UPDATE to modify the records.The objectname is table name which is Employee.The user name is Ahmad.
ii) To revoke the permission to view and modify the records in the table Employee.
The DCL Command is--
REVOKE SELECT,UPDATE on Employee from Ahmad.
Explanation: Firstly to revoke the permissions to user,We have to use REVOKE command.The privileges Need to revoke are SELECT because to view the records and UPDATE to modify the records.The objectname is table name which is Employee.The user name is Ahmad.
Hope you understand and like the answer.
Thank you..