In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What is the isolation level of transactions in the database? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
MySQL transactions are mainly used to deal with data with large amount of operations and high complexity. For example, in the personnel management system, if you delete a person, you need to delete not only the basic information of the person, but also the information related to the person, such as mailboxes, articles, etc., so that these database operation statements constitute a transaction!
In MySQL, only databases or tables that use the Innodb database engine support transactions.
Transactions can be used to maintain the integrity of the database, ensuring that batches of SQL statements are either executed or not executed.
Transactions are used to manage insert,update,delete statements
The four isolation levels of the transaction:
1. Read Uncommitted-- read unsubmitted content
A transaction can view uncommitted content
Dirty reading problems often occur (dirty reading: reading uncommitted (executed) content of other transactions)
Open An and B transactions (An and B transaction crossover) start transaction for the same data table
A transaction only queries the contents of the data table, while B transaction does add, delete and modify operations but does not commit (commit)
A transaction can still query the data changes in the table (query to uncommitted content-dirty read)
2. Read Committed-- read the submission
A transaction can only view committed content
It often gives rise to the problem of non-repeatable reading (unrepeatable reading: executing the same select statement in the same transaction to get different results)
Open An and B transactions (An and B transaction crossover) start transaction for the same data table
A transaction only queries the contents of the data table, while B transaction does add, delete and modify operations but does not commit (commit)
A transaction query cannot find the contents of the data changes in the table
B transaction commit
A found data changes (A two queries, resulting in different results-non-repeatable)
3. Repeatable Read-re-readable
Multiple instances of the same transaction get the same result when reading data concurrently
Default transaction isolation level for MySQL
Often produce phantom reading problems (phantom reading: different results when reading multiple times (phantom lines))
Open An and B transactions (An and B transaction crossover) start transaction for the same data table
A transaction only queries the contents of the data table, while B transaction does add, delete and modify operations but does not commit (commit)
A transaction query cannot find the contents of the data changes in the table
B transaction commit
A transaction query cannot find the contents of the data changes in the table
A submit
A can query the changes of the data in the table
4. Serializable-serializable
Maximum isolation level
Add a shared lock to the transaction, and there can be only one transaction operation to solve the phantom reading problem.
It can lead to a lot of timeouts and lock competition problems.
Open A transaction
The operation cannot be added or deleted when the B transaction is started.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.