Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL Database Promotion-transactions

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Day08 MySQL Database Promotion-transactions

I. Overview of transactions:

Transactions, which are made up of one or more sql statements in a single unit, are also an important part of the MySQL database. Each unit is interdependent and cannot be separated as a whole. If an error or failure occurs in a unit, the whole unit will be rolled back and all affected data will be returned to the state before the start of the transaction.

2. Transaction:

1. Nature of the transaction:

Atomicity: a transaction is a whole and cannot be divided.

Consistency: in the process of dealing with a transaction, both the success of the transaction and the failure of some links will lead to success or failure.

Isolation: each transaction takes place in its own space and does not affect other transactions.

Persistence: a committed transaction persists even if the database crashes.

2. Steps to create a transaction:

2.1. Initialize the transaction:

Start transaction

2.2. Create a transaction

Here we use an insert command to create a transaction insert into student (id,name,password) values (001 recording xxxx recording recording yyyyy')

2.3. Check that the data is entered normally.

Select * from student where id=001

2.4. Commit transaction

Commit

3. Undo transaction (transaction rollback)

Rollback

4. Set MySQL control behavior

4.1. Turn off autocommit

Set autocommit = 0

4.2. View the status of automatic submission

Select @ @ autocommit

III. Concluding remarks

At this point, the transaction of the MySQL database is finished, which is the most basic thing. Learn these things well and be able to use them in the follow-up development process. So that you can go further.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report