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


你可能感兴趣的:(mysql 批量删除)