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

What are the transaction types of mysql?

PHPz
Release: 2023-05-31 23:16:05
forward
1836 people have browsed it

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)
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template