Describe a various transaction control command of sql?
Transaction Control Commands in SQL
1. COMMIT:
Commit is a transaction control command in SQL that is used to save all the changes made during the current transaction. When a COMMIT command is executed, all the changes made by the transaction are permanently saved in the database. This means that the changes become permanent and cannot be rolled back.
2. ROLLBACK:
Rollback is another transaction control command in SQL that is used to undo all the changes made during the current transaction. When a ROLLBACK command is executed, all the changes made by the transaction are discarded, and the database is rolled back to the state it was in before the transaction started. This is useful in case of errors or if the transaction needs to be cancelled.
3. SAVEPOINT:
Savepoint is a command in SQL that allows you to create a point within a transaction to which you can later rollback. This is useful when you want to undo only a portion of the transaction rather than the entire transaction. Savepoints can be nested within transactions, allowing for more granular control over the rollback process.
4. SET TRANSACTION:
SET TRANSACTION is a command in SQL that is used to set the characteristics of a transaction. This command allows you to specify properties such as isolation level, access mode, and read-only status for the transaction. By using SET TRANSACTION, you can customize the behavior of the transaction to suit your specific requirements.
Using these transaction control commands in SQL, you can effectively manage and control the changes made to the database within a transaction, ensuring data integrity and consistency.