No problem with code configuration, why not ROLLBACK transaction (to understand MySQL database engine)

Source: Internet
Author: User

In the development of the problems encountered in the first few days, during the debugging process found that the configuration service this transaction does not work layer, after the update database throws an exception or success, the transaction will not be rolled back. The various checks are then started, and the view spring's transactions are configured correctly and the transaction is turned on when the Update method is entered. After checking that everything is OK, why does the transaction not roll back? The problem is a very difficult place to consider (the tables created in the database do not support transactions).

The MySQL database default creation table engine is: MYISAM, the table using such an engine is highly efficient. However, we do not support transactions, so we should be in the construction of the table is best based on the need to manually specify the engine we need, the following is a can support the transaction of the SQL table, you can take a look:

CREATE TABLE   Test (ID varchar (+)  PRIMARY KEY, name varchar (+), create_time datetime, Create_user varchar (+), a ddress varchar (not NULL, remark varchar) ENGINE = InnoDB DEFAULT Charset=utf8
Note:ENGINE = InnoDBThis configuration is to choose which engine, innodb such an engine to support the transaction.

The following are descriptions of the various engines common to MySQL databases. To understand, we will be able to choose the right engine the next time we create the table.

ISAM: Index order Access Mode (index sequential)

ISAM is a well-defined and time-tested form of data management that, at design time, takes into account that the number of times the database is queried is much larger than the number of updates. As a result, ISAM runs read operations very quickly and does not consume a large amount of memory and storage resources.

The two main disadvantage of ISAM is that it does not support transactional processing. Nor can it be fault-tolerant. Assuming your hard drive crashes, the data file cannot be recovered. Assuming you are using ISAM in mission-critical applications, you must often back up all of your real-time data, and with its replication features, MySQL can support this backup application.
Default storage engine for Myisam:mysql

MyISAM is the ISAM extended format for MySQL and the default database engine. In addition to providing a large number of functions for index and field management that are not available in ISAM, MyISAM also uses a mechanism for table locking. To optimize multiple concurrent read and write operations, the cost is that you are often required to execute the Optimize table command to restore the wasted space of the updated mechanism. MyISAM other useful extensions, such as MYISAMCHK tools for repairing database files and Myisampack tools for recovering wasted space. MyISAM emphasizes high-speed read operations, which may be the main reason why MySQL is so popular with Web development: in Web development, the bulk of your data operations are read operations. Therefore, most virtual hosting providers and Internet platform providers simply agree to use the MyISAM format. An important flaw in the MyISAM format is the inability to recover data after a table is corrupted.

HEAP:

The heap agrees to a temporary table that resides only in memory. Residing in memory makes the heap faster than ISAM and MyISAM, but the data it manages is unstable. And assume that it was not saved before shutting down the machine. Then all the data will be lost. The heap does not waste a lot of space when data rows are deleted.

The heap table is useful when you need to select and manipulate data using the Select expression.

Remember to delete the table after you have finished using the table.

InnoDB:

The InnoDB database engine is a direct product of the technology that makes MySQL flexible. This technology is the mysql++ API. Every challenge you face when using MySQL comes almost to the ISAM and MyISAM database engine does not support transactional processing (transaction process) or foreign keys. Although much slower than ISAM and MyISAM engines, InnoDB contains support for transactional and foreign keys. These two points are not the first two engines. Assuming that your design requires accesses than either or both of these features, you will be forced to use one of the InnoDB and Berkley engines, and we often use InnoDB.

InnoDB provides MySQL with a transaction-safe (acid-compatible) storage engine with Commit, rollback, and crash resiliency.

InnoDB locks the row level and also provides an Oracle-style, non-locking read in the SELECT statement, which adds multiuser deployment and performance. There is no need to widen the lock in the InnoDB. Because the row-level lock in InnoDB is suitable for very small spaces.

InnoDB also supports foreign key coercion. In the SQL query. You are free to mix tables of the InnoDB type with other MySQL table types, even in the same query. This is the official description of MySQL.

It is speculated that many people want to know more to check online ...

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

Code configuration is not a problem, why not rollback the transaction (to understand the MySQL database engine)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.