delimiter $$ // 定义结束符为 $$ drop procedure if exists wk; // 删除 已有的 存储过程 create procedure wk() // 创建新的存储过程 begin declare i int; // 变量声明 set i = 1; while i < 11 do // 循环体 insert into user_profile (uid) values (i); set i = i +1; end while; end $$ // 结束定义语句 // 调用 delimiter ; // 先把结束符 回复为; call wk();
CREATE PROCEDURE 存储过程名称( [in | out | inout] 参数 ) BEGIN Mysql 语句 END
call 存储过程名称() // 名称后面要加()
<span style="color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(250, 247, 239);">二 、 REPEAT 循环</span>
<pre name="code" class="html">delimiter // drop procedure if exists looppc; create procedure looppc() begin declare i int; set i = 1; repeat insert into user_profile_company (uid) values (i+1); set i = i + 1; until i >= 20 end repeat; end // ---- 调用 call looppc()
delimiter $$ drop procedure if exists lopp; create procedure lopp() begin declare i int ; set i = 1; lp1 : LOOP // lp1 为循环体名称 LOOP 为关键字insert into user_profile (uid) values (i); set i = i+1; if i > 30 then leave lp1; // 离开循环体 end if; end LOOP; // 结束循环 end $$
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有