Home > Article > Daily Programming > What does transaction mean in mysql data table?
This article mainly introduces to you what transactions in mysql data tables refer to and what their functions are?
The concept of mysql transactions, I believe some friends have encountered it in various interview questions about mysql.
What is transaction (Transaction) in mysql? What is the use?
Simply put, a transaction is a sequence of database operations defined by the user. These operations are either done or not done. It is an indivisible unit of work, generally referring to what is to be done. or something done. We can also understand that a transaction is composed of one or more SQL statements. If any of the statements cannot be completed or an error occurs, then all SQL statements in this unit will give up execution, so only all statements in the transaction will succeed. Only when it is executed successfully can we say that the transaction was successfully executed!
In other words, a transaction is a program execution unit that accesses and updates various data items in the database, that is, a set of synchronously executed and uncommitted SQL DML (insert, update, delete) statements. This is the basis of database operations. A unit!
And generally, a transaction corresponds to a complete business, and a program may also contain multiple transactions. For example, salary transfer, bank transfer, commodity purchase and other services.
With this introduction, everyone should have a preliminary understanding of transactions in mysql.
Some friends may ask, What is the use of affairs? What is transaction security?
MySQL transactions are mainly used to process data with large operations and high complexity.
Transaction security: In order to ensure that the results of a series of operations remain synchronized and the integrity of the data is ensured.
Automatically commit transactions: Every time a SQL statement is executed, it is synchronized to the database.
Manual submission of transactions: execute a series of sql statements and then synchronize them to the database
We can give a simple example to understand the role of transactions, For example, when we are shopping on Taobao (there is a transaction), when we successfully submit the order and are prompted that the payment has been completed, the Internet is suddenly disconnected. At this time, when we refresh the page, we can find that the payment has been successful. On the contrary (no transaction), if we have clearly paid, but due to a sudden disconnection, when we refresh the page, the payment will be displayed again!
Through this simple example, everyone must have a better understanding of the role of transactions.
Let me give you a brief summary of the characteristics of transactions. This knowledge point is also very common in our mysql interview questions.
Characteristics of transactions (Transaction)
1. Atomicity: Atomicity means that a transaction is an indivisible unit of work. Either all or none of the operations will occur.
2. Consistency: In a transaction, the integrity of the data before and after the transaction must be consistent. You can imagine bank transfers and train ticket purchases.
3. Isolation: Multiple transactions. The isolation of transactions means that when multiple users access the database concurrently, the transactions of one user cannot be interfered by the transactions of other users. Between multiple concurrent transactions, Data must be isolated from each other.
4. Durability: Durability means that once a transaction is committed, its changes to the data in the database are permanent. Even if the database fails, it should not have any impact. .
This article is an introduction to the specific knowledge about the definition and function of transactions in mysql data tables. It is easy to understand. I hope it will be helpful to friends in need!
If you want to know more about mysql, you can follow the PHP Chinese website mysql video tutorial, everyone is welcome to refer to and learn!
The above is the detailed content of What does transaction mean in mysql data table?. For more information, please follow other related articles on the PHP Chinese website!