DELETE FROM minute1_pp01temp WHERE id> 111352;
...
...
[SQL] DELETE FROM minute1_pp01temp WHERE id> 111352;
受影响的行: 448
时间: 0.016s
[SQL] DELETE FROM minute1_pp01temp WHERE id> 111352;
受影响的行: 448
时间: 0.016s
DELIMITER $$
CREATE PROCEDURE delete_temp_tab()
BEGIN
REPEAT
DELETE FROM test.`tab` WHERE id > 111352 LIMIT 1000;
UNTIL ROW_COUNT()=0 END REPEAT;
END $$
DELIMITER ;
CALL delete_temp_tab();
DROP PROCEDURE IF EXISTS delete_temp_tab;
你先 select count 一下看看,id > 111352的 记录有多少,然后再删除!!
1、mysql删除大量数据,直接delete会锁表,用存储过程循环执行delete比较方便。
例如:
2、要么就是把需要的数据导入到一张新的表中,再把原表删除。