What is Transaction?
Collection of operation that forms a single logical unit of work is called transactions. Transaction is any activity that modifies existing records. Transaction is very complicated task it involves activities like sending email, transferring account balance from one account to another, modifying records, recharging your mobile phone, shaping using cards etc. the transaction basically operates on database at time data base is access by different transactions so it is very important to keep database in consistent state this is called as transaction management. Before transaction takes place it important to that it should satisfy certain constraint for example if we try to withdraw 500 dollars from your bank account and your current account balance is 400 dollars then this is not valid transaction.
Problems in Transaction
Basically computer system is not very reliable it is subject to failure so we if problem occur at middle of the transaction then database remains in inconsistent state, this can be explained with the help of example suppose we want to transfer 500 dollars from account A to Account B the first step would be deduct 500 from account A if system fails at this stage then amount will not get add in account B and 500 dollars will get deduct from account A then where does 500 go? Another problem is transaction occurs when two or more process access same value in database it is called as concurrent execution.
Acid Properties of Transaction
Transaction is an atomic work of done it either fails or succeed. If transaction successfully completed then it its committed if anything goes wrong whole transaction is rolled back. This ensures database in consistent state.
This property ensures transaction is consistent state for example if transaction fails then its roll back
If multiple transactions are executing concurrently it should guarantee that they should not access same data item at time only one process can access at a times.
This ensures that when transaction completed successfully the changes it has made to the database must be saved in spite of any system failure.
The transaction can be in any of the following states.
This is initial state of transaction when transaction begins it is in this state.
Here all operations of transactions are completed but it is not written to database yet.
Transaction cannot be proceed further some problem is occurred.
During transaction if any problem occurs then we have to restore original values.
Transaction is completed now and it is successfully written to database.
Transactions Definition in SQL
Commit is statement commit all changes to database.
Rollback is the statement which undoes all changes made to the database if any problem occurs in database then we execute rollback statement.
The save point is used as a flag after execution of each statement using roll back you can undo all transaction but if you want to undo transaction up to specific point then you can use this save point statement. For more reading about technology news in singapore and seo to online marketing do view more about other pages.