Mysql Delete operation

Source: Internet
Author: User

The following is excerpted from the official documentation:

Grammar:

DELETE [low_priority] [QUICK] [IGNORE] Fromtbl_name[PARTITION (partition_name,...)] [WHEREwhere_condition] [ORDER by ...] [LIMITrow_count]


Performance:
When you don't need to know the number of deleted rows, theTRUNCATE TABLEStatement is a faster-to-empty a table than aDELETEStatement with noWHEREClause. UnlikeDELETE,TRUNCATE TABLECannot is used within a transaction or if you have a lock on the table. Seesection 14.1.34, "TRUNCATE TABLE Syntax" and section 14.3.5, "LOCK TABLES and UNLOCK TABLES Syntax".
The simple understanding is: Truncate in the case of not locking the table, soon:

If you want to delete the quick point with delete:
The time required to delete individual rows in aMyISAMTable is exactly proportional to the number of indexes. To delete rows more quickly, you can increase the size of the key in the cache by increasing thekey_buffer_sizeSystem variable
Key_buffer_size size that can be configured
Multiple table deletions:
(1) without aliases
DELETE T1, t2 from T1 INNER join T2 INNER join T3where t1.id=t2.id and t2.id=t3.id;

Or:

DELETE from T1, T2 USING T1 INNER join T2 INNER join T3where t1.id=t2.id and t2.id=t3.id;
(2) Aliases: Must write aliases:

If you declare an alias for a table, you must use the alias when referring to the table:

DELETE t1 from test as T1, Test2 WHERE ...

Correct:

DELETE A1, A2 from T1 as A1 INNER joins T2 as A2where a1.id=a2.id;delete from A1, A2 USING T1 as A1 INNER join T2 as A2wher E a1.id=a2.id;



Mysql Delete operation

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.