0% found this document useful (0 votes)
46 views6 pages

Week 08 - Tutorial Lab Sheet DCL

This document discusses the Data Control Language (DCL) commands in SQL. It explains that DCL is used to define database access privileges and permissions. The key DCL commands are GRANT, which grants user privileges, and REVOKE, which revokes previously granted privileges. Examples are given of using DCL commands to create and manage users, assign privileges to databases and schemas, and remove privileges and users.

Uploaded by

Tuan Ajreen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views6 pages

Week 08 - Tutorial Lab Sheet DCL

This document discusses the Data Control Language (DCL) commands in SQL. It explains that DCL is used to define database access privileges and permissions. The key DCL commands are GRANT, which grants user privileges, and REVOKE, which revokes previously granted privileges. Examples are given of using DCL commands to create and manage users, assign privileges to databases and schemas, and remove privileges and users.

Uploaded by

Tuan Ajreen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Week 08 – Tutorial of Data

Control Language (DCL) of


Structured Query Language
(SQL)
ITE 2422 - Database
Management Systems

Akila Warnapura
ITE 2422 - Database Management Systems Lecture Name:
Akila Warnapura Data Control Language (DCL)
Learning Outcomes
§ After completing this tutorial, you will learn about
SQL commands of Data Control Language (DCL)

ITE 2422 - Database


Management Systems

Akila Warnapura

Lecture Name:
Data Control Language (DCL)
Structured Query Language Commands

§ DDL - Data Definition Language


§ DCL - Data Control Language
§ DML - Data Manipulation Language
§ DQL - Data Query Language

ITE 2422 - Database


Management Systems

Akila Warnapura

Lecture Name:
Data Control Language (DCL)
Structured Query Language Commands

§ DCL - Data Control Language


DCL or Data Control Language is used to define the database system's rights,
permissions, and other controls.

The following is a list of DCL commands:

§ GRANT:
This command grants users database access privileges.
§ REVOKE:
This command revokes the access privileges granted to the user via the ITE 2422 - Database
GRANT command. Management Systems

Akila Warnapura

Lecture Name:
Data Control Language (DCL)
DCL - Data Control Language
The followings are examples of DCL commands
select user from mysql.user;
This command is used to show all users in the MySQL Server

create user 'kasun'@'localhost' identified by '123’;


This command is used to create a new user called ‘kasun’ in the ‘localhost’ with the password = ‘123’

alter user 'kasun'@'localhost' identified by '456’;


This command is used to change the password to ‘456’ of user called ’kasun’

ITE 2422 - Database


grant all privileges on myTestDb.* to 'kasun'@'localhost’; Management Systems
This command is used to grant all the privileges on all the tables of schema called ‘myTestDb’ to user
‘kasun’ Note: This user ‘kasun’ will not be allowed to grant privileges to other users.
Akila Warnapura

grant create, alter, drop, insert, update, delete, select, references, reload on Lecture Name:
myTestDb.* to ‘kasun'@'localhost’; Data Control Language (DCL)
This command is used to grant specific privileges on all the tables of schema called ‘myTestDb’ to user
‘kasun’ Note: This user ‘kasun’ will not be allowed to grant privileges to other users.
DCL - Data Control Language
The following is examples of DCL commands

grant all privileges on myTestDb.* to 'kasun'@'localhost’ with grant option


This command is used to grant all the privileges on all the tables of schema called ‘myTestDb’ to user
‘kasun’ Note: This user ‘kasun’ will be allowed to grant privileges to other users.

flush privileges
When the CREATE USER or GRANT statements are executed, this command reloads the grant tables to
ensure that the newly created privileges are applied

revoke all privileges on myTestDb.* from 'kasun'@'localhost’ ITE 2422 - Database


It is necessary to run this command in order to completely delete all of the privileges of the user ‘kasun’ in Management Systems
the database 'myTestDb’.
Akila Warnapura
drop user 'kasun'@'localhost’
This command is used to remove the user ‘kasun’ from the ‘localhost’ Lecture Name:
Data Control Language (DCL)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy