Answer» - The sequence of actions (SQL statements) served as a single unit that is called a transaction. Transaction Management places an important ROLE in RDBMS-oriented applications to maintain data consistency and integrity.
- Transaction Management can be described well – by using ACID properties. ACID STANDS for Atomicity, Consistency, Isolation, and Durability.
- Atomicity - If all queries are successfully executed, then only data will be committed to the database.
- Consistency - It ensures bringing the database into a consistent STATE after any transaction.
- Isolation - It ensures that the transaction is isolated from other transactions.
- Durability - If a transaction has been committed once, it will remain always committed, even in the situation of errors, power loss, etc.
- Need for Transaction Management:
When creating a connection to the database, the auto-commit mode will be selected by default. This implies that every time when the request is executed, it will be committed automatically upon completion. We might want to commit the transaction after the execution of few more SQL statements. In such a situation, we must set the auto-commit value to False. So that data will not be able to commit before EXECUTING all the queries. In case if we get an exception in the transaction, we can rollback() changes MADE and make it like before.
|