mysql delete limit優點:
用於DELETE的MySQL唯一的LIMIT row_count選項用於告知服務器在控制命令被返回到客戶端前被刪除的行的最大值。本選項用於確保一個DELETE語句不會占用過多的時間。您可以只重復DELETE語句,直到相關行的數目少於LIMIT值為止。
如果DELETE語句包括一個ORDER BY子句,則各行按照子句中指定的順序進行刪除。此子句只在與LIMIT聯用是才起作用。例如,以下子句用於查找與WHERE子句對應的行,使用timestamp_column進行分類,並刪除第一(最舊的)行:
DELETE FROM somelog WHERE user = 'jcole' ORDER BY timestamp_column LIMIT 1;
delete limit使用方法:
單表語法:delete [low_priority] [quick] [ignore] from tbl_name
[where where_definition]
[order by ...]
[limit row_count]
刪除所有行
可以在不刪除表的情況下刪除所有的行。這意味著表的結構、屬性和索引都是完整的:
delete from table_name
或者:
delete * from table_name
下在為刪除指定區別如0,30
delete from db limit 0,30
這裡基本我測試都通不過,delete from db limit 30 是可以測試通過的,不知道是不是我的版本問題
好像limit 後面是指刪除多少條記錄,並沒有給像select 中的起始記錄數樣!
然後如果我想limit 30 應該是刪除默認的,也就跟select * from db limit 0, 30差不多,
select from `sheet1` where 1 limit 0, 1
delete from `sheet1` where 1 limit 1
對於記錄數較多的情況,我們一般用limit 100
delete from tag_list where aid='6666' limit 100;
delete表連接不支持limit,該如何處理
delete表連接不支持limit
mysql> delete test1 from test1 join test2 on test1.id=test2.id limit 10;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 10' at line 1
mysql>
------解決思路----------------------
delete A FROM test1 A INNER JOIN (SELECT ID FROM test2 limit 10) B
on A.id=B.id ;