MySQL DML operation suggestions

Source: Internet
Author: User

(I) INSERT large data volume

(1) Replace a single row with multi-row insert: insert into t values (),(),(),...

(2) load data infile... into table t

(3) Write a temporary table and INSERT... SELECT

(4) cancel the index and constraints, and re-build the data after loading.

DELAYED attribute specified during INSERT

For InnoDB, partitions can be divided into multiple transactions and submitted in batches.

(Ii) large data volume UPDATE

Before that, we should disable indexes and related constraints.

① SELECT unique field, change field

② Write the result set to a temporary table

③ Create a composite index for a temporary table

④ Each record of the cyclic temporary table

⑤ Update the change field of the target table based on the unique field of the temporary table

(Iii) large data volume DELETE

① Partitioned table

② Obtain the unique identifier of the data to be deleted to the temporary table and batch delete of the cursor Loop

Recommended reading:

PL/SQL ORA-14551: cannot perform DML operations in queries solved

Common MySQL DDL, DML, and DCL languages (example)

Execute batch DML exercises for Oracle basic transactions and ForAll

Oracle DML Statement (insert, update, delete) rollback Estimation

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.