DROP PROCEDURE
IF EXISTS test_data;
DELIMITER $$
CREATE PROCEDURE test_data()
BEGIN
-- 定义变量
DECLARE i INT UNSIGNED DEFAULT 1; -- 1是变量可以写10000
-- 循环次数
WHILE i <= 100 DO -- i是变量可以 <10000
insert into kt_circle(
name,
avatar,
bg_url,
type,
hot,
create_time,
update_time) VALUES ("测试学校",
"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.gongyinglian.51sole.com%2F20170829%2Fb_201708291818360551.jpg&refer=http%3A%2F%2Fimg2.gongyinglian.51sole.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1655363422&t=002f7f3b8e8649b7a57d897f03a0968d",
"https://img2.baidu.com/it/u=1066853283,1331990121&fm=253&fmt=auto&app=120&f=JPEG?w=959&h=500",
1,
1,
now(),
now());
SELECT i;
SET i = i+1;
END WHILE;
END $$
--
CALL test_data();
Mysql 循环插入测试数据 SQL
最新推荐文章于 2024-07-19 03:25:55 发布