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
• 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
• 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