SQL GRANT REVOKE Commands
SQL GRANT REVOKE Commands
ON object_name
REVOKE privilege_name
ON object_name
Creating Roles:
The Syntax to create a role is:
CREATE ROLE role_name
[IDENTIFIED BY password];
For Example: To create a role called "developer" with password as "pwd",the
code will be as follows
CREATE ROLE testing
[IDENTIFIED BY pwd];
It's easier to GRANT or REVOKE privileges to the users through a role rather
than assigning a privilege directly to every user. If a role is identified by a
password, then, when you GRANT or REVOKE privileges to the role, you
definitely have to identify it with the password.
We can GRANT or REVOKE privilege to a role as below.
For example: To grant CREATE TABLE privilege to a user by creating a testing
role:
First, create a testing Role
Second, grant a CREATE TABLE privilege to the ROLE testing. You can add more
privileges to the ROLE.
To revoke a CREATE TABLE privilege from testing ROLE, you can write: