TRANSACTION CONTROL LANGUAGE (TCL)
Learning Objectives: Students
will be able to:
• To understand and use TCL
commands (COMMIT, ROLLBACK,
SAVEPOINT) to control database
transactions.
• To learn how VIEW and SYNONYM
are created and used to simplify
queries and manage data access.
• To understand the role of INDEX in
improving the performance of SQL
queries.
DBMS LAB
1. TRANSACTION CONTROL
LANGUAGE (TCL)
• TCL commands manage
database transactions.
• A transaction is a group of
SQL statements treated as
one unit of work.
• TCL helps save changes
permanently or undo
changes to maintain data
consistency.
DBMS LAB
TRANSACTION CONTROL LANGUAGE (TCL) :
DBMS LAB
DBMS LAB
Types of TRANSACTION CONTROL
LANGUAGE (TCL) :
• The COMMIT command
permanently saves all changes
made during the current
transaction to the database.
Syntax:
COMMIT;
Example:
INSERT INTO Student VALUES (101,
'Amit', 85);
COMMIT;
DBMS LAB
COMMIT
ROLLBACK
The ROLLBACK command is used
to undo changes made in the
current transaction since the last
COMMIT or ROLLBACK.
Syntax:
ROLLBACK;
Example:
DELETE FROM Student WHERE
RollNo = 101;
ROLLBACK;
DBMS LAB
SAVEPOINT
DBMS LAB
SAVEPOINT is used to set a point
within a transaction to which a
rollback can be performed.
Syntax:
SAVEPOINT savepoint_name;
Example:
SAVEPOINT sp1;
UPDATE Student SET Marks = 90
WHERE RollNo = 102;
ROLLBACK TO sp1;
Database Object:
Database Objects in SQL are
logical structures created in a
database to store, manage, and
access data efficiently.
DBMS LAB
Database Object:
DBMS LAB
• A View is a virtual table based
on the result of a SELECT query.
It does not store data
physically but displays data
from one or more tables.
Syntax:
CREATE VIEW view_name AS
SELECT column1, column2
FROM table_name
WHERE condition;
View:
DBMS LAB
Example:
CREATE VIEW Student_View AS
SELECT RollNo, Name
FROM Student
WHERE Marks > 60;
SELECT * FROM view_name;
Example:
DROP VIEW Student_View;
View:
DBMS LAB
• A Synonym is an alternative
name for a database object
such as a table, view,
sequence, or procedure. It
simplifies object access and
improves security.
Syntax:
CREATE SYNONYM
synonym_name
FOR object_name;
Example:
CREATE SYNONYM stud FOR
Student;
SYNONYMS:
DBMS LAB
• An Index is a database object
used to improve the speed of
data retrieval operations on a
table. Indexes are created on
columns frequently used in
search conditions.
Syntax:
CREATE INDEX index_name
ON table_name(column_name);
Example:
CREATE INDEX idx_rollno
ON Student(RollNo);
INDEXES
DBMS LAB
• TCL manages database
transactions and ensures data
consistency by allowing users to
save or undo changes.
• Database Objects are logical
structures in SQL used to store,
manage, and retrieve data
efficiently.
• Views, Synonyms, and Indexes
are types of database objects
used to simplify data access,
improve security, and enhance
query performance.
Summary:
DBMS LAB
LET’S BEGIN…

Transaction Control Language in SQL/PL SQL

  • 1.
  • 2.
    Learning Objectives: Students willbe able to: • To understand and use TCL commands (COMMIT, ROLLBACK, SAVEPOINT) to control database transactions. • To learn how VIEW and SYNONYM are created and used to simplify queries and manage data access. • To understand the role of INDEX in improving the performance of SQL queries. DBMS LAB
  • 3.
    1. TRANSACTION CONTROL LANGUAGE(TCL) • TCL commands manage database transactions. • A transaction is a group of SQL statements treated as one unit of work. • TCL helps save changes permanently or undo changes to maintain data consistency. DBMS LAB
  • 4.
  • 5.
    DBMS LAB Types ofTRANSACTION CONTROL LANGUAGE (TCL) :
  • 6.
    • The COMMITcommand permanently saves all changes made during the current transaction to the database. Syntax: COMMIT; Example: INSERT INTO Student VALUES (101, 'Amit', 85); COMMIT; DBMS LAB COMMIT
  • 7.
    ROLLBACK The ROLLBACK commandis used to undo changes made in the current transaction since the last COMMIT or ROLLBACK. Syntax: ROLLBACK; Example: DELETE FROM Student WHERE RollNo = 101; ROLLBACK; DBMS LAB
  • 8.
    SAVEPOINT DBMS LAB SAVEPOINT isused to set a point within a transaction to which a rollback can be performed. Syntax: SAVEPOINT savepoint_name; Example: SAVEPOINT sp1; UPDATE Student SET Marks = 90 WHERE RollNo = 102; ROLLBACK TO sp1;
  • 9.
    Database Object: Database Objectsin SQL are logical structures created in a database to store, manage, and access data efficiently. DBMS LAB
  • 10.
  • 11.
    • A Viewis a virtual table based on the result of a SELECT query. It does not store data physically but displays data from one or more tables. Syntax: CREATE VIEW view_name AS SELECT column1, column2 FROM table_name WHERE condition; View: DBMS LAB
  • 12.
    Example: CREATE VIEW Student_ViewAS SELECT RollNo, Name FROM Student WHERE Marks > 60; SELECT * FROM view_name; Example: DROP VIEW Student_View; View: DBMS LAB
  • 13.
    • A Synonymis an alternative name for a database object such as a table, view, sequence, or procedure. It simplifies object access and improves security. Syntax: CREATE SYNONYM synonym_name FOR object_name; Example: CREATE SYNONYM stud FOR Student; SYNONYMS: DBMS LAB
  • 14.
    • An Indexis a database object used to improve the speed of data retrieval operations on a table. Indexes are created on columns frequently used in search conditions. Syntax: CREATE INDEX index_name ON table_name(column_name); Example: CREATE INDEX idx_rollno ON Student(RollNo); INDEXES DBMS LAB
  • 15.
    • TCL managesdatabase transactions and ensures data consistency by allowing users to save or undo changes. • Database Objects are logical structures in SQL used to store, manage, and retrieve data efficiently. • Views, Synonyms, and Indexes are types of database objects used to simplify data access, improve security, and enhance query performance. Summary: DBMS LAB
  • 16.