MySQL: transaction management-to be continued

Source: Internet
Author: User
Tags savepoint

Logical Transaction Management-basically applied to the InnoDB Engine

    • Begin [work] Start transaction [with consistent snapshot]
    • Commit [work] [and [no] Chain] [[No] Release]
    • Rollback [work] [and [no] Chain] [[No] Release]
    • Set autocommit = {1 (default) | 0}

MySQL has a certain transaction management mode.

    • The completion_type system variable determines the behavior pattern of a transaction after completion.
    • The autocommit system variable determines whether the transaction is automatically committed after completion!
    • In storageProgramInternal: Begin [work] is regarded as a simple begin end block, rather than the start of the transaction. To start a transaction, use start transaction.
    • Mysql client APIs usually have their own expression for starting transactions.
    • Starting a transaction will result in the implicit commit of the transaction that has completed the suspension. It will also automatically release the "Table lock" obtained using the lock tables statement, as if the unlock tables statement was executed; however, the global read lock obtained by flush tables with read lock will not be released"
    • Many MySQL statements (generally DDL statements: {create | drop} database, {create | alter | drop} {tables | routines}) do not include such statements in transactions, otherwise, rollback fails.
    • Many MySQL statements may cause implicit commit of transactions, such as DDL statements, DCL statements, file system related statements, and transaction management statements.

 

Transaction savepoint

    • Savepoint svp_name -- if the name of the new transaction storage point and the existing same, the old
    • Rollback [work] to [savepoint] svp_name -- the transaction rolls back to the specified storage point
    • Release savepoint svp_name: Delete the transaction retention point defined in the statement. Note that the transaction commit or rollback will not be caused.

Table lock

    • Lock tables {table_name [[as] alias] {read [Lock] | [low_priority] wirte} [,...]
    • Unlock tables

Transaction isolation level
Set [Global | SESSION (default)] transaction isolation level {read uncommitted | Read committed | Repeatable read | serializable}

XA transaction

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.