Get the App
SLTechnology News&Howtos  ›  Database  › 

Simple steps for MySQL transaction execution

Shulou Source: shulou.com Published: 2022-06-01 19:40:13 09月18日 Update

The following is mainly to bring you simple steps of MySQL transaction execution, I hope these words can bring you practical use, this is also the main purpose of my editing MySQL transaction execution simple steps this article. Okay, no more nonsense, let's go straight to the following.

A transaction can consist of a series of sql statements, and its execution is atomic.

1. Atomicity:

Contains multiple sql statements that either execute successfully or fail to execute successfully

2. Rollback:

Go back to the original unexecuted state

Create a table first

create table user(id int primary key auto_increment,name char(32),balance int);

insert data

insert into user(name,balance)values('wsb',1000),('egon',1000),('ysb',1000);

began to implement

start transaction; update user set balance=900 where id=1;update user set balance=1010 where id=2;update user set balance=1090 where id=3;commit; write MySQL, so that you really cannot rollback

rollback; If there is no commit, then executing this statement will roll back to the original unexecuted state

For the above simple steps on MySQL transaction execution, do you think it is very helpful? If you need to know more, please continue to pay attention to our industry information, I believe you will like these contents.

Tags: Transaction step statement success following text content atom state or multiple actual nonsense data text more usefulness purpose article industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei vpn Docker Xiaomi