MySQL存储过程
2015-07-06 17:02
543 查看
简单的存储过程示例
1.查看已存在的存储过程 sql里面输入 show procedure status dos命令里面输入 show procedure status\G;
2.删除存储过程 Drop procedure 存储过程的名称
3.调用存储过程 call 存储过程名字()
4.创建一个简单的查询存储过程
delimiter $
create procedure p1()
begin
select * from beautiful.member_base_info;
end$
5.创建一个if else 存储过程
delimiter $
create PROCEDURE p3(n int ,n1 char(1))
begin
if n1='n' then
select * from beautiful.member_base_info where id > n;
else
select * from beautiful.member_base_info where id < n;
end if;
end$
6.创建一个while循环存储过程
delimiter $
create procedure p4(n SMALLINT)
BEGIN
DECLARE i int;
DECLARE s int;
set i=1;
set s=0;
while i <= n do
set s=s+i;
set i=i+1;
end while;
select s;
END$
1.查看已存在的存储过程 sql里面输入 show procedure status dos命令里面输入 show procedure status\G;
2.删除存储过程 Drop procedure 存储过程的名称
3.调用存储过程 call 存储过程名字()
4.创建一个简单的查询存储过程
delimiter $
create procedure p1()
begin
select * from beautiful.member_base_info;
end$
5.创建一个if else 存储过程
delimiter $
create PROCEDURE p3(n int ,n1 char(1))
begin
if n1='n' then
select * from beautiful.member_base_info where id > n;
else
select * from beautiful.member_base_info where id < n;
end if;
end$
6.创建一个while循环存储过程
delimiter $
create procedure p4(n SMALLINT)
BEGIN
DECLARE i int;
DECLARE s int;
set i=1;
set s=0;
while i <= n do
set s=s+i;
set i=i+1;
end while;
select s;
END$
相关文章推荐
- MySQL中的integer 数据类型
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复
- MySQL 优化
- MySQL 数据类型
- Facebook's New Real-time Messaging System: HBase to Store 135+ Billion Messages a Month