快速创建存储过程
CREATE TABLE IF NOT EXISTS `index_user`(
`id` INT UNSIGNED AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`email` VARCHAR(40) NOT NULL,
`mobile` BIGINT(11) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
DELIMITER //
CREATE PROCEDURE proc21()
BEGIN
DECLARE k INT;
SET k = 10;
TRUNCATE TABLE index_user;
SET autocommit=0;
SET unique_checks=0;
WHILE k < 100 DO
INSERT INTO
`index_user`
(
`id`,
`name`,
`email`,
`mobile`,
`submission_date`
)
VALUES (
k,
CONCAT(k,'tester'),
CONCAT(k,'tester@qq.com'),
15000000000 + k,
NOW()
);
SET k = k + 1;
END WHILE;
SET autocommit=1;
SET unique_checks=1;
END
//
DELIMITER ;
-- 调用
call proc21();
drop procedure proc21;
-- 删除表数据
-- truncate table index_user;