DCL Full Form
DCL stands for Data Control Language in Structured Query Language (SQL). As the name suggests these commands are used to control privilege in the database. The privileges (Right to access the data) are required for performing all the database operations like creating tables, views, or sequences.
DCL command is a statement that is used to perform the work related to the rights, permissions, and other control of the database system.
There are two types of Privileges in database:
- System Privilege
- Object Privilege
Need Of DCL commands
- Unauthorized access to the data should be prevented in order to achieve security in our database
- DCL commands maintain the database effectively than anyone else other than database administrator is not allowed to access the data without permission.
- These commands provide flexibility to the data administrator to set and remove database permissions in granular fashion.
Commands in DCL
The two most important DCL commands are:
This command is used to grant permission to the user to perform a particular operation on a particular object. If you are a database administrator and you want to restrict user accessibility such as one who only views the data or may only update the data. You can give the privilege permission to the users according to your wish.
GRANT privilege_list ON Object_name TO user_name;
This command is used to take permission/access back from the user. If you want to return permission from the database that you have granted to the users at that time you need to run REVOKE command.
REVOKE privilege_list ON object_name FROM user_name;
Following commands are granted to the user as a Privilege List:
Advantages Of DCL commands
- It allows to restrict the user from accessing data in database.
- It ensures security in database when the data is exposed to multiple users.
- It is the wholesome responsibility of the data owner or data administrator to maintain the authority of grant and revoke privileges to the users preventing any threat to data.
- It prevents other users to make changes in database who have no access to Database