0% found this document useful (0 votes)
9 views7 pages

DBMS Exp 6

Uploaded by

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

DBMS Exp 6

Uploaded by

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

EXPERIMENT NO.

AIM: Perform DCL and TCL commands.

THEORY:
DCL commands manage permissions and access control in SQL databases. The two main DCL
commands are GRANT and REVOKE.
1.GRANT:
Definition: Provides privileges to users.
Syntax:
grant privilege_name on object_name to user_name;
Example:
grant select, insert on employees to John;
Explanation:
This grants SELECT and INSERT privileges on the employees table to the user John.
2.REVOKE:
Definition: Removes privileges from users.
Syntax:
revoke privilege_name on object_name from user_name;
Example:
revoke insert on employees from John;
Explanation:
This revokes the INSERT privilege on the employees table from the user John
Transaction Control Language (TCL)
TCL commands handle transactions in a database. Common TCL commands include
COMMIT, ROLLBACK, and SAVEPOINT.
1.COMMIT:
Definition: Saves all changes made in the current transaction.
Syntax:
commit;
Example:
update students set grade = 'A' where student_id = 1;
commit;
Explanation:
This updates the grade of the student with student_id = 1 to 'A' and saves the change
permanently.
ROLLBACK: Undoes all changes made in the current transaction before the COMMIT.
Syntax:
rollback;
Example:
delete from students where student_id = 2;
rollback;
Explanation:
This deletes the student with student_id = 2, but the ROLLBACK undoes the deletion.

SAVEPOINT: Creates a point in the transaction to which you can later roll back.
Syntax:
savepoint savepoint_name;
Example:
update students set grade = 'B' where student_id = 3;
savepoint sp1;
update students set grade = 'C' where student_id = 4;
rollback to sp1;
Explanation:
This updates the grade of the student with student_id = 3 to 'B', sets a savepoint, and then
updates the grade of the student with student_id = 4 to 'C'. The rollback undoes the change
made to student_id = 4, but keeps the change for student_id = 3.
Create a user:

Grant one privilege to user:

Grant multiple privileges to user:

Grant all privileges to user:

Revoke one privilege from user:


Revoke two privileges from user:

Revoke all privileges from user:

Create a role:

Grant privileges to role:

Assign role to user:


Commit:

Rollback:
Create savepoints:
Rollback to a savepoint:

CONCLUSION:
In this experiment, we used DCL commands like GRANT and REVOKE to manage user
permissions, and TCL commands such as COMMIT, ROLLBACK, and SAVEPOINT to control
transactions. These commands help manage database security and ensure changes can be
saved or undone as needed.

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