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

Introduction of transaction control statements in MySQL 5.7s

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

Share

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

A START TRANSACTION or BEGIN statement starts a transaction

The COMMIT statement commits the transaction so that the changes to the data take effect permanently

The ROLLBACK statement rolls back the transaction and cancels changes to the data

The SET autocommit statement disables or enables the default transaction auto-commit feature for the current session

-- example

Mysql > START TRANSACTION

Query OK, 0 rows affected (0.00 sec)

Mysql > SELECT @ A:=SUM (deptno) FROM test

+-+

| | @ A:=SUM (deptno) |

+-+

| | 150 |

+-+

1 row in set (0.00 sec)

Mysql > UPDATE test SET deptno=@A WHERE deptno=10

Query OK, 1 row affected (0.05sec)

Rows matched: 1 Changed: 1 Warnings: 0

Mysql > commit

Query OK, 0 rows affected (0.01 sec)

-- turn off the auto-commit function of the current session transaction

Mysql > SET autocommit=0

Query OK, 0 rows affected (0.00 sec)

Mysql > show variables like'% commit%'

+-+ +

| | Variable_name | Value |

+-+ +

| | autocommit | OFF |

| | innodb_commit_concurrency | 0 | |

| | innodb_flush_log_at_trx_commit | 1 | |

+-+ +

3 rows in set (0.00 sec)

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