如何删除其中有大约160万行的mysql表中的行
答
如果你想'回应',你可以反复使用这批。我使用你没有任何指标(指数将在where子句好):
DELETE FROM `table`
WHERE (whatever criteria if any)
ORDER BY `id`
LIMIT 1000
还有另外一种方式我看了,但从来没有尝试过:
for i in `seq 1 1000`; do
mysql -e "select id from table_name where (condition) order by id desc limit 1000 " | sed 's;/|;;g' | awk '{if(NR>1)print "delete from table_name where id = ",$1,";" }' | mysql;
done
如果你还在寻找对于更快的方式,请尝试以下方法:
CREATE TABLE new_tbl LIKE tbl;
RENAME TABLE tbl TO old_tbl, new_tbl TO tbl;
DROP TABLE old_tbl;
你认为什么是“没有回应”?你用什么来截断?你等了多久?请详细说明你的问题 – Emobe