1、查询数据
CREATE DEFINER=`root`@`%` PROCEDURE `myproc`()
BEGIN
SELECT * from mytest;
END
2、插入数据(传入参数)
CREATE DEFINER=`root`@`%` PROCEDURE `myinsert`(IN `id` int,IN `name` varchar(255),IN `age` int)
BEGIN
INSERT into mytest(id, name, age) VALUES(id, name, age);
END
3、查询数据(输出参数)
CREATE DEFINER=`root`@`%` PROCEDURE `myselect`(OUT `age` int)
BEGIN
SELECT @age=age from mytest WHERE id=1;
END
4、循环体结构
CREATE DEFINER=`root`@`%` PROCEDURE `myinsert80`(IN `i` int)
BEGIN
while @i < 100
do
INSERT into mytest(id, name, age) VALUES(@i, '45', 66);
set @i = @i + 1;
end while;
END
参考链接
【】
标签:存储,END,int,age,过程,id,DEFINER,CREATE From: https://www.cnblogs.com/ReturnOfTheKing/p/17236587.html