1. 程式人生 > >儲存過程批量插入表資料

儲存過程批量插入表資料

DELIMITER ;; 
CREATE  PROCEDURE test_insert() 
BEGIN 
DECLARE X BIGINT DEFAULT 128;
DECLARE Y VARCHAR(13) DEFAULT '13660000128';
DECLARE Z BIGINT DEFAULT 128;


WHILE X<3000
DO
INSERT INTO df2017_apply(ID,NAME,ORG,POST_NAME,PHONE,OPEN_ID,CREATE_DATE,CREATE_BY,UPDATE_DATE,UPDATE_BY) VALUES(X,1,1,1,Y,Z,NOW(),1,NOW(),1); 
SET Y=Y+1; 
SET X=X+1;
SET Z=Z+1;
END WHILE ; 
COMMIT; 
END;; 
CALL test_insert();

--刪除表資料
TRUNCATE TABLE df2017_lottery_result;
SELECT COUNT(*) FROM df2017_lottery_result a WHERE   a.prize_id='1005';

SELECT * FROM df2017_lottery_result a, df2017_lottery_result b WHERE a.id<>b.id AND a.apply_id=b.apply_id;