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

Does mysql need commit?

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of whether mysql needs commit, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this mysql article. Let's take a look at it.

In mysql, whether commit is needed depends on the storage engine: 1. If a storage engine that does not support transactions, such as myisam, does not need to use commit;2, if it supports transactions, such as innodb, you need to know whether transactions commit automatically, so you need to use commit.

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

Does mysql need commit?

Whether mysql needs commit when adding, deleting or modifying depends on your storage engine.

If the engine that does not support transactions, such as myisam, then whether commit is not effective.

If it is an engine that supports transactions, such as innodb, you need to know whether things support autocommit transactions (that is, commit)

To see if your database is automatic commit, you can use the

Mysql > show variables like'% autocommit%'

To check, if it is OFF, it does not automatically commit, you need manual commit operation (the command line can directly "commit;" command), otherwise it is automatic commit.

Expand knowledge:

There are three types of submission data: explicit submission, implicit submission, and automatic submission.

These three types are described below.

Explicit submission

A commit that is done directly with the COMMIT command is an explicit commit.

Implicit submission

A commit that is done indirectly with the SQL command is an implicit commit. These commands are:

ALTER, AUDIT, COMMENT, CONNECT, CREATE, DISCONNECT, DROP, EXIT, GRANT, NOAUDIT, QUIT, REVOKE, RENAME .

Automatic submission

If AUTOCOMMIT is set to ON, after the insert, modify and delete statements are executed

The system will submit automatically, which is called automatic submission. Its format is: SQL > SET AUTOCOMMIT ON

Be careful when using the COMMIT / ROLLBACK commands. COMMIT / ROLLBACK is used after the execution of DML statements (INSERT / DELETE / UPDATE / SELECT). After the DML statement is executed, the data processed will be placed in the rollback segment (except the SELECT statement), waiting for the user to submit (COMMIT) or ROLLBACK (rollback). When the user executes COMMIT / ROLLBACK, the data placed in the rollback segment will be deleted.

(after the SELECT statement is executed, the data exists in the shared pool. When it is provided to others to query the same data, it is directly extracted in the shared pool, and there is no need to extract it from the database, which improves the speed of data query. )

All DML statements are explicitly committed, that is, the COMMIT is executed after the DML statement is executed. Others, such as DDL statements, are implicitly submitted. That is, after running those non-DML statements, the database has been implicitly committed, such as CREATE TABLE, after running the script, the table has been built, and you are no longer required to explicitly commit.

This is the end of the article on "whether mysql needs commit". Thank you for reading! I believe you all have a certain understanding of "whether mysql needs commit". If you want to learn more, you are welcome to follow the industry information channel.

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