返回顶部

收藏

mysql 批量删除

更多
CREATE PROCEDURE  del_line()

BEGIN 

      DECLARE count_line INT;

        /** 先删除索引提高删除速度*/

ALTER TABLE `test_road_1`.`lebp_logistics_line`  

DROP INDEX index_carrier_id,

DROP INDEX index_state,

DROP INDEX index_leave_city,

DROP INDEX index_leave_city_area,

DROP INDEX index_arrive_city,

DROP INDEX index_arrive_city_area,

DROP INDEX index_mock_attachment;

SELECT COUNT(*) INTO count_line FROM lebp_logistics_line;

WHILE count_line > 0 DO 

   DELETE FROM lebp_logistics_line LIMIT 10000 ;

   COMMIT ;

   SET count_line = count_line - 10000 ;

END WHILE ;

END

标签:sql

收藏

0人收藏

支持

0

反对

0

发表评论