DCL Commandss
DCL includes commands such as GRANT and REVOKE which mainly deal with the rights, permissions, and other controls of the database system.
- GRANT
- REVOKE
DCL includes commands such as GRANT and REVOKE which mainly deal with the rights, permissions, and other controls of the database system.
This command gives users access privileges to the database.
We have already learned about how to create user in MySQL using MySQL | create user statement. But using the Create User Statement only creates a new user but does not grant any privileges to the user account.Therefore to grant privileges to a user account, the GRANT statement is used.
GRANT privileges_names ON object TO user;
Parameters Used:
The privileges that can be granted to the users are listed below along with description:
Privilage | Description |
---|---|
SELECT | Select statement on tables. |
INSERT | Insert statement on the table |
DELETE | Delete statemnet on the table |
INDEX | Create an index on an existing table |
CREATE | Create table statement |
ALTER | Ability to performe ALTER TABLE to change the table definition |
DROP | Drop table statement |
ALL | Grant all permission exept GRANT OPTION |
UPDATE | Update statement on the table |
GRANT | Allows to grant the privilage |
Let us now learn about different ways of granting privileges to the users:
ALTER TABLE table_name ADD(column_name datatype);