SQL learning. Transactions

Source: Internet
Author: User

1. Regarding the concurrency issue, that is, if I am browsing, and another user is modifying. An error occurs.
SET transaction read only
Select * from MERs where name = 'tree ';
Commit;
2. p227 transactions and rollback.
Same life and death ..
The transaction is identified by begin transaction and end transaction. The update and delete statements or all of them are not executed .. For example:
Begin transaction T1
Update student
Set Name = 'tank'
Where id = 2006010.
Delete from student
Where id = 2006011.
Commit
End transaction T1
3.
Simply put, transactions are a mechanism used to maintain the integrity of the database.

The implementation form is to embed common SQL statements into Tran in Tran... in commit Tran (or full form begin transaction... commit transaction), of course, you can also use rollback Tran to roll back the transaction, that is, to cancel the operation.

Using the transaction mechanism, you can either execute all database operations or not execute all operations to ensure Database Consistency. The SQL statements that require transactions are usually update and delete operations.

One thing to note is that transactions do not support nesting, that is, they are not allowed to appear in a form similar to this:
Begin tran
...
Begin tran
...
Commit tran
...
Commit tran

Of course, the query operation does not need to use transactions, because the query does not change the data and does not damage the integrity.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.