Home >Database >Mysql Tutorial >What are the transaction types of mysql?

What are the transaction types of mysql?

PHPz
PHPzforward
2023-05-31 23:16:051840browse

1. MySQL transactions are divided into explicit transactions and implicit transactions. The default transaction is an implicit transaction, and the variable autocommit will automatically open, commit and rollback during operation.

2. For explicit transactions, we control the opening, submission, rollback and other operations of the transaction ourselves.

Example

-- 看下当前autocommit的状态是,默认是on状态
mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | ON    |
+---------------+-------+
1 row in set (0.01 sec)
 
--  插入一条数据
mysql> insert into ajisun values(1,'阿纪');
Query OK, 1 row affected (0.00 sec)
mysql> rollback;
 
-- 执行rollback 也是没有效果的,还是能够查询到插入的数据(不需要我们手动控制commit)
mysql> select * from ajisun;
+------+--------+
| id   | name   |
+------+--------+
|    1 | 阿纪   |
+------+--------+
1 row in set (0.00 sec)

The above is the detailed content of What are the transaction types of mysql?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete