文章列表
mysql存储过程读书笔记(3): 变量
- 博客分类:
- mysql
1. 变量名: Mysql变量名推荐30个字符以内,命名要有实际意义
2. 声明变量的方式:
declare variable_name[,variable_name,....] datatype [default value];
可以同时定义多个具有相同类型的变量,如果没有default表达式,则默认变量声明之后默认值是Null
declare 普通变量应该在所有declare cursor语句和declare continue handler语句之前
3.变量类型:
int/integer: 32位整数(可以声明为unsigned)
...
1. If
create procedure example3(stu_id int) begin declare stu_name varchar(30); select name into stu_name from student where student_id = stu_id; If stu_name is not null Then select stu_name; End If;End;
2. If ... Else....
create procedure example4(stu_id int) begin ...
mysql 存储过程读书笔记(1)基础
- 博客分类:
- mysql
mysql存储过程目前只支持存储过程,存储函数,触发器
存储过程基本结构:
Create procedure ProcedureName(Params[in,out])
Begin
Declare attr attrType;
procedure content;
End;
Example:
1. 创建基本存储过程
create procedure exampe1()begin declare l_student_count integer; select count(*) into l_student_count from ...