循环插入1w条数据
表结构:
mysql> desc time_table;
+-------+-----------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+-----+-------------------+-----------------------------+
| b1 | date | YES | | NULL | |
| b2 | time | YES | | NULL | |
| b3 | datetime | YES | | NULL | |
| b4 | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+-------+-----------+------+-----+-------------------+-----------------------------+
4 rows in set (0.00 sec)
插入时间数据:
drop procedure if exists lr_time;
delimiter $$
create procedure lr_time()
begin
declare n int default 1;
declare MAX int default 10001;
while n < MAX do
insert into time_table values (curdate(), curtime(), now(), localtimestamp());
set n = n + 1;
select sleep(1);
end while;
end
$$
delimiter ;
call lr_time();
相关文章
暂无评论...