DML SQL
DML SQL
DML SQL
LANGUAGE
Understanding The SELECT Statement :
An Overview of Data Retrieval in SQL
•Basic Syntax:
SELECT column1, column2, ...
FROM table_name;
KEY FEATURES OF
SELECT
•Filtering: Use the WHERE clause to specify conditions.
Purpose Syntax
Committing changes ensures the changes are The basic syntax is: COMMIT;
permanent, preventing data loss in case of unexpected
issues.
Importance of Transaction Management
Transaction management is vital for maintaining data integrity, consistency, and reliability in database systems.
1 Atomicity 2 Consistency
All changes within a transaction are treated as a single Transactions ensure data remains consistent by adhering
unit; either all changes are applied or none. to predefined rules and constraints.
3 Isolation 4 Durability
Concurrent transactions are isolated from each other, Once a transaction commits, the changes are permanent
preventing interference and maintaining data integrity. and persist even in the event of system failures.
Best Practices for Using COMMIT
Using COMMIT effectively enhances the reliability and efficiency of your database applications.
Commit Frequently 1
Commit changes frequently to avoid losing significant work
in case of unexpected errors or system failures.
2 Avoid Unnecessary COMMITs
Unnecessary COMMITs can impact performance, so only
commit when necessary.
Use ROLLBACK for Errors 3
If an error occurs during a transaction, use ROLLBACK to
undo all changes and maintain consistency.
Conclusion and Key
Takeaways
Understanding and effectively using TCL in MySQL is crucial for
building robust and reliable database applications.
If an error occurs during the execution of the transaction, you can rollback
the entire set of changes, effectively undoing them. Rollbacks in databases
are commonly used to maintain data integrity and ensure that only valid
changes are committed
Points to be noted :
• While we write/create any query for creating database (the action of creating
the database is done by TCL(Transaction Control Language.
Syntax : ROLLBACK;
Use of
SAVEPOINT
SAVEPOINT is used only to mark the position of a transaction, it doesn’t save anything,creates
a savepoint within the current transaction.
The SAVEPOINT command in TCL is basically used to temporarily save a transaction so that
we can roll back to that point (saved point) whenever required.
SAVEPOINT enables us to do partial rollbacks providing more control over which parts of a
transaction to undo.
Points to be noted :
Syntax : SAVEPOINT
savepoint_name;