Data Control Language (DCL)

DCL Commands:

These commands are used to control access to and manage database security. They grant or revoke privileges to users, ensuring data protection and integrity.

 

  1. GRANT:

 

It is employed to grant a privilege to a user. GRANT command allows specified users to perform specified tasks

 

Syntax:

GRANT select,update,delete,insert,alter on Employee to Surya ;Example:

In the above statement you are allowing to modify records to surya employee

Example 1:

Granting SELECT, INSERT, and UPDATE permissions on a table:

GRANT SELECT, INSERT, UPDATE ON Customers TO sales_team;

Example 2:

Granting all permissions on a database:

GRANT ALL ON MyDatabase TO admin_user;

Example 3:

Granting the ability to grant permissions to others:

GRANT SELECT ON Orders TO manager WITH GRANT OPTION;

  1. REVOKE:

Withdraws previously granted privileges from users or roles.

Example:

REVOKE DELETE ON Orders FROM junior_employees;

This revokes the DELETE privilege on the Orders table from users with the junior_employees role.

Example 2:

Revoking INSERT permission on a table:

REVOKE INSERT ON Employees FROM interns;

Example 3:

Revoking all permissions granted by a specific user:

REVOKE ALL PRIVILEGES ON MySchema FROM manager;

 

Related Posts

Join Our Newsletter