mysql--transactions

Source: Internet
Author: User

In Windows when we installed MySQL:

1. The concept of a transaction

A transaction is a set of SQL statement operations, and the individual SQL statements that make up this set of operations must all succeed in order to result. Any SQL statement execution fails and the end result will not actually execute.

2. Transaction and Storage Engine

The storage engine of the table must be innodb;

3. Transaction processing1) Open transaction

Start transaction; | Begin

Modify the default SQL statement terminator

Because there are many SQL statements in the transaction, by default, the statement terminator for MySQL is ";" So the default terminator to modify, modify the method: Delimiter statement Terminator

Statement Terminator can be customized, "$$", $$$,%%%,////,//, ....

For example, modify the default statement terminator to//

Delimiter//

2) Commit the transaction

1 Commit

3) Rolling back transactions
1 rollback;

1. Characteristics of transactions (ACID) 1) atomicity (atomicity): A transaction consists of one or a set of interrelated SQL statements that are considered an indivisible unit. 2) Consistency (consistency): Transactional consistency means that the database must be in a consistent state before and after a transaction is executed. This feature is known as transactional consistency 3) Isolation (Isolation): Each transaction has its own space, the execution of a transaction is not disturbed by other transactions 4) persistence (durability): Changes to the data after committing the transaction are updated Permanent.

mysql--transactions

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.