0% found this document useful (0 votes)
4 views9 pages

A154_Exp9

The document is a lab manual for a Database Management System course, focusing on Transaction Control Language (TCL) and Data Control Language (DCL). It outlines the aims, prerequisites, outcomes, and theoretical concepts related to transaction management, including commands like COMMIT, ROLLBACK, and SAVEPOINT, as well as user privilege management with GRANT and REVOKE. Students are required to complete practical tasks and reflect on their learning regarding these commands and their significance in database operations.

Uploaded by

ayanmir2005
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)
4 views9 pages

A154_Exp9

The document is a lab manual for a Database Management System course, focusing on Transaction Control Language (TCL) and Data Control Language (DCL). It outlines the aims, prerequisites, outcomes, and theoretical concepts related to transaction management, including commands like COMMIT, ROLLBACK, and SAVEPOINT, as well as user privilege management with GRANT and REVOKE. Students are required to complete practical tasks and reflect on their learning regarding these commands and their significance in database operations.

Uploaded by

ayanmir2005
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/ 9

SVKM’s NMIMS

Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)


Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

PART A
(Part A: TO BE REFERRED BY STUDENTS)
Experiment No. 09
A.1 AIM:
To study and understand Transaction Control Language (TCL) using commands like Commit,
Rollback and create save point and use it with Rollback.

To study Data Control Language (DCL) using commands like GRANT and REVOKE

A.2 Pre requisite:


DML commands of SQL, concept of transaction and DCL .

A.3 Outcome:
After successful completion of this experiment students will be able to

1. Understand the importance of transaction control commands in database management


systems.
2. Create the multiple users and grant some privileges as per their requirements and revoke
permission from the ussers.

A.4 Theory:

Transaction:
A transaction is a logical unit of work that contains one or more SQL statements. A
transaction is an atomic unit. The effects of all the SQL statements in a transaction can be
either all committed (applied to the database) or all rolled back (undo from the database).

A transaction begins with the first executable SQL statement. A transaction ends when it is
committed or rolled back, either explicitly with a COMMIT or ROLLBACK statement or
implicitly when a DDL statement is issued.
SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

There are following commands used to control transactions:

COMMIT: to save the changes permanently.

ROLLBACK: to roll back the changes.

SAVEPOINT: creates points (or bookmark) within groups of transactions in which to


ROLLBACK SET

TRANSACTION: Places a name on a transaction.

Transactional control commands are only used with the DML commands INSERT, UPDATE
and DELETE only. They cannot be used while creating tables or dropping them because these
operations are automatically committed in the database.

1. COMMIT Command:
The COMMIT command is the transaction control command used to save changes invoked by a
transaction to the database.

The COMMIT command saves all transactions to the database since the last COMMIT or
ROLLBACK command.

Syntax for commit command:


commit;

Example:

SQL> DELETE FROM CUSTOMERS WHERE AGE = 25;

SQL> COMMIT;

2. The Rollback command:

The ROLLBACK command is the transactional command used to undo transactions that have
not already been saved to the database.

The ROLLBACK command can only be used to undo transactions since the last COMMIT or
ROLLBACK command was issued.
SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

The syntax for Roll back command:

ROLLBACK;

For example

SQL> DELETE FROM CUSTOMERS WHERE AGE = 25;

SQL> ROLLBACK;

3. The Savepoint Command:


A SAVEPOINT is a point in a transaction when you can roll the transaction back to a certain
point without rolling back the entire transaction.

The syntax for SAVEPOINT command is as follows:

SAVEPOINT SAVEPOINT_NAME;

This command serves only in the creation of a SAVEPOINT among transactional statements.
The ROLLBACK command is used to undo a group of transactions.

The syntax for rolling back to a SAVEPOINT is as follows:

SQL> SAVEPOINT
ROLLBACK SP1;
TO SAVEPOINT_NAME;

Savepoint created.
Example:
SQL> DELETE FROM CUSTOMERS WHERE ID=1;

1 row deleted.

SQL> SAVEPOINT SP2;


SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

SQL> DELETE FROM CUSTOMERS WHERE ID=2;

1 row deleted.

SQL> SAVEPOINT SP3;

Savepoint created.

SQL> DELETE FROM CUSTOMERS WHERE ID=3;

1 row deleted.

SQL> ROLLBACK TO SP2;

Rollback complete.

SQL> select * from table_name;

Deleted records of ID=2 and ID=3 will be rollbacked.

DCL (Data Control Language)

DCL includes commands such as GRANT and REVOKE which mainly deal
with the rights, permissions, and other controls of the database system.

List of DCL commands:

GRANT: This command gives users access privileges to the database.


REVOKE: This command withdraws the user’s access privileges given by using the
GRANT
Syntax with descriptions:
, UPDATE ON MY_TABLE FROM USER1, USER2;
SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

PART B
(PART B: TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments within two hours of the practical.
The soft copy must be uploaded on the Blackboard or emailed to the concerned lab in charge
faculties at the end of the practical in case the there is no Black board access available)

Roll No. :A154 Name:Krish Patel


Class :Btech AI & DS Batch :2
Date of Experiment :03/04/25 Date/Time of Submission :04/04/25
Grade :

B.1 Tasks given in PART A to be completed here

SQL Queries:

-- Creating table

CREATE TABLE Student (

ID INT PRIMARY KEY,


SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

Name VARCHAR(50),

Marks INT

);

-- Inserting records

INSERT INTO Student VALUES (1, 'Amit', 85);

INSERT INTO Student VALUES (2, 'Bhagyashree', 90);

SAVEPOINT A;

INSERT INTO Student VALUES (3, 'Ravi', 70);

SAVEPOINT B;

UPDATE Student SET Marks = 95 WHERE Name = 'Bhagyashree';

SAVEPOINT C;

-- Rolling back to savepoint B

ROLLBACK TO B;

-- Committing the transaction

COMMIT;

DCL Commands:

-- Creating a new user


SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

CREATE USER test_user IDENTIFIED BY password;

-- Granting privileges

GRANT SELECT, INSERT ON Student TO test_user;

-- Revoking privileges

REVOKE INSERT ON Student FROM test_user;

B.2 Conclusion:

Output (Expected):

• First two records inserted.

• Savepoint A created.

• Third record inserted and Savepoint B created.

• Bhagyashree’s marks updated and Savepoint C created.

• ROLLBACK TO B reversed mark update.

• COMMIT saved changes up to Savepoint B.

• New user created and privileges granted/revoked as expected.

In this experiment, I learned how Transaction Control Language (TCL) commands like
COMMIT, ROLLBACK, and SAVEPOINT are used to manage data consistency in SQL
databases. I also understood the concept of Data Control Language (DCL), which is used to
assign and remove privileges for database users. These commands are crucial in multi-user
environments to ensure secure and reliable data operations.
SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

B.3 Question of Curiosity

(To be answered by student based on the practical performed and learning/observations)

1. What is a transaction?

A transaction is a logical unit of work that consists of one or more SQL operations. It ensures
data consistency and is either fully completed or fully rolled back.

2. What is rollback and commit command? Explain with an example.

• ROLLBACK undoes changes made during the transaction.

• COMMIT saves all the changes made.

Example:

INSERT INTO Student VALUES (4, 'Neha', 88);

ROLLBACK; -- Neha's record will not be saved

INSERT INTO Student VALUES (5, 'Rohan', 91);

COMMIT; -- Rohan’s record will be saved permanently

3. What was your observation about savepoint command? Explain with an example.

SAVEPOINT allows setting a point within a transaction to which you can roll back without
affecting all changes.

Example:

SAVEPOINT A;

UPDATE Student SET Marks = 99 WHERE ID = 2;


SVKM’s NMIMS
Mukesh Patel School of Technology Management & Engineering (Mumbai Campus)
Computer Engineering Department (B Tech CSE/CSBS Sem IV/BTI Sem
VIII/MBA.Tech-IV)
Database Management System
Lab Manual

ROLLBACK TO A; -- Reverts only the last update, keeping earlier operations intact

4. Discuss the role of DCL commands in a multiuser environment.

DCL commands like GRANT and REVOKE help manage database security by giving or
restricting access to users. In a multi-user setup, this prevents unauthorized access and ensures
each user has only the permissions they need.

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