What are transactions and their controls?
What are transactions and their controls?
Software Developer
Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I completed MCA with 76% form Veer Bahadur Singh Purvanchal University Jaunpur. SWE @ MindStick | Software Engineer | Web Developer | .Net Developer | Web Developer | Backend Engineer | .NET Core Developer
Transactions are a group of database commands that can change or access data stored in a database. A transaction is considered a single unit of work and is known to maintain the integrity of data in the database.
Transaction control statements include:
Syntax:
2. ROLLBACK: The ROLLBACK command is used to undo saved changes made by the transaction in the database.
Syntax:
3. SAVEPOINT: SAVEPOINT is a point in the groups of transactions to roll back.
Syntax:
4. SET TRANSACTION: The SET TRANSACTION command is used to initiate a database transaction.
Syntax:
SQL Transaction:
A transaction is a group of operations that are treated as just one logical operation.
For example: When we withdraw money from our bank account or deposit money in the bank account.
Property of Transaction (ACID Properties) :- Transaction has four properties which we call ACID Properties.
1-Atomicity
2-Consistency
3-Isolation
4-D-Durability
1-Atomicity:- When the transaction is completed in a single step then the transaction is atomic.
2:-Consistency:- When the transaction takes place, the database is consistence from one state to another.
3:-Isolation:- When two or more transactions are executed simultaneously, then one transaction does not affect the other transaction.
4:-Durability:- When a transaction is completely completed then the changes that take place stay in the system permanently. That is, the transaction should be durable.
Transaction Control:
The following commands are used to control the transaction-
1- COMMIT: This command is used to save the changes in database table.
2- ROLLBACK: It is used to roll back the changes.
3- SAVE POINT: It creates the points within the group of multiple transactions in which to rollback.
4- SET TRANSACTION: It place a name on a transaction.