by, 03-09-2012 at 07:29 PM (575 Views)
In a database, at the same time two users might be accessing the similar data. E.g if one user is reading columnís value from database and other one is updating column at the same time. This is possible that 1st user may get old & update data, at the same time.
To prevent these situations, transactions are provided by DBMS so that to maintain data in persistent state. More than 1 user may access database with data concurrency, at the same time.
More than 1 SQL statements which create a logical work unit is known as a transaction. In given states, transaction might end.
Such states are dependent on the problems associated with concurrency or data consistency.
- The commit statement makes permanent changes to the database.
- The rollback statement is involved in undoing all alterations that have resulted from the SQL.
For prohibiting 2 transactions to be manipulating similar data concurrently, use lock mechanism.
E.g. in case a table is locked you canít drop it, when uncommitted transaction is present. Rows are locked with table lock in some DBMS.