DELIMITER $$ #以delimiter来标记用$表示存储过程结束
CREATE PROCEDURE ownerapartment() ##创建pre()存储方法
BEGIN
DECLARE i INT; #定义i变量
SET i=1;
WHILE i<35 DO #对i的值配置
INSERT INTO owner_apartment (id, owner_id,
property_id, community_id, building_id,
element_id, apartment_id, owner_type,
effective_start_time, effective_end_time
)
VALUES (i, i,
i, i, i,
i,i, i%2,
'2019-07-31 00:00:00', '2019-07-31 00:00:00'
);
SET i=i+1; #自增循环
END WHILE;
END
$$ #存储过程结束
DROP PROCEDURE ownerapartment; #删除存储过程
CALL ownerapartment(); #使用存储过程
MySql 创建存储过程
最新推荐文章于 2022-07-16 16:19:01 发布