---
title: "MySQL学习笔记－－DELETE and TRUNCATE"
author: "realizeamg"
date: "2009-08-22T16:35:54Z"
tags: []
slug: "mysql-delete-and-truncate"
draft: false
lastmod: "2009-09-15T13:20:39Z"
id: 455483
url: "https://realizeamg.iteye.com/blog/455483"
---

1:DELETE
DELETE FROM table_name  LIMIT count

WHERE条件复杂，涉及到其他表的话，需要使用USING
DELETE FROM table_a, table_b USING table_a, table_b, table_c, table_d
WHERE ....;

但DELETE的WHERE clause中不支持nested subquery，同样在多表DELETE的时候也不
能使用ORDER BY和LIMIT

mysql支持通过limit来对删除结果的条数进行限制

2:TRUNCATE
通过removing和re-creating表结构来完成数据删除，比DELETE更快，但MySQL不会统计删除的行数。另外，对TRUNCATE的使用还有两个限制：
(1)对InnoDB tables，DELETE和TRUNCATE实际是等效的
(2)不支持locking或者transactions