What is role? How can we authorize a user using grant and revoke command? Give example.
In : BE Subject : Database Management Systemsa role is a named collection of privileges that can be assigned to users to simplify authorization management. Instead of granting individual permissions to each user, the database administrator can group related privileges into a role and then assign that role to users. This makes it easier to manage access control, especially when dealing with a large number of users.
Authorization in SQL is mainly managed using the GRANT and REVOKE commands:
-
GRANT Command:
The GRANT command is used to provide specific privileges to a user or a role. Privileges can include operations such asSELECT,INSERT,UPDATE, orDELETEon database objects.
Syntax:GRANT privilege_name ON object_name TO user_name;
GRANT SELECT, INSERT ON Students TO User1; - REVOKE Command:
The REVOKE command is used to remove previously granted privileges from a user or a role.
Syntax:
REVOKE privilege_name ON object_name FROM user_name;
REVOKE INSERT ON Students FROM User1;
-
A role groups privileges for easier management.
-
GRANT gives privileges to users or roles.
-
REVOKE removes privileges from users or roles.