Database Languages – TCL (Transaction Control Language)
Oracle SQL examples for managing transactions and ensuring data integrity.
TCL (Transaction Control Language) is used to manage transactions in a database, ensuring ACID properties and data consistency.
1. What is TCL?
- Controls transactions made by DML commands.
- Ensures atomicity, consistency, isolation, durability (ACID).
- Only affects data changes, not structure.
2. Common TCL Commands
| Command | Purpose | Oracle Example |
|---|---|---|
| COMMIT | Save changes permanently | COMMIT; |
| ROLLBACK | Undo changes in transaction | ROLLBACK; |
| SAVEPOINT | Set a point to rollback partially | SAVEPOINT sp1; |
3. Oracle Examples in Detail
COMMIT Example
INSERT INTO student VALUES (101, 'Ahsan', 'DBMS'); COMMIT;
ROLLBACK Example
INSERT INTO student VALUES (102, 'Arif', 'AI'); ROLLBACK;
SAVEPOINT Example
INSERT INTO student VALUES (103, 'Rafi', 'DBMS'); SAVEPOINT sp1; UPDATE student SET course='AI' WHERE student_id=103; ROLLBACK TO sp1;
4. Key Points
- Manages transactions after DML operations.
- Ensures data integrity and ACID compliance.
- COMMIT saves permanently, ROLLBACK undoes changes.
- SAVEPOINT allows partial rollbacks within a transaction.
5. Summary
TCL (Transaction Control Language) ensures safe and consistent database operations. Commands include COMMIT, ROLLBACK, SAVEPOINT to manage transactions and maintain data integrity.
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন