Search

Saturday, May 26, 2012

DCL–Data control language

DCL means Data Control Language. DCL is used to grant , revoke permissions on SQL Server objects to the SQL Server Users and Roles.


Some example of DCL statement are : GRANT, REVOKE


GRANT - gives a user permission to perform certain tasks on database objects
REVOKE - removes a grant or deny permission from a user on certain database objects



The GRANT statement is used to give permissions to a user or role to perform certain tasks on database objects. It is possible to assign permissions to both statements as well as objects by using the GRANT statement. You can use the GRANT statement with the WITH GRANT OPTION clause to permit the user or role receiving the permission to further grant/revoke access to other accounts.
This example grants the SELECT permission on the authors table to Arun

GRANT SELECT ON authors TO Arun

The REVOKE statement is used to remove a previously granted or denied permission from a user in the current database. You can use the REVOKE statement to remove both statements and objects permissions. You can specify the GRANT OPTION FOR clause with the REVOKE statement to remove the WITH GRANT OPTION permissions. Therefore, the user will have the objects permissions, but cannot grant the permissions to other users. 
The following example revokes SELECT permissions to the authors table from the user, Arun:

REVOKE SELECT ON authors TO Arun

1 comment: