mysql ????????????????????????(???)??????
mysql ????????????????????????(1)?????? mysql?????????????????????????????????????????????????????????????????? ????????????????????????: Create procedure ProcedureName(Params[in,out]) Begin ???????? Declare?? attr attrType; ??????????proce
mysql ????????????????????????(1)??????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 student;
??
?????????? ??select concat('there are totally ', l_student_count ,' students');
end;
??
2.??????????????????
???? drop procedure example1;
??
3.??????????????????????????????
create procedure example2(stu_id int)
begin
?????? declare stu_name varchar(30);
??
???????? select name into stu_name from student where student_id = stu_id;
???????? select stu_name;
end;
??
4.????????????????????????
create function example5() returns int
begin
???????? declare student_count int;
??
?????????? select count(*) into student_count from student;
?????????? return student_count;
end;
??
5.???????????????????????????
create trigger example6 before update on t for each row
begin
???? If New.percent ???? ????set New.percent = 20;
???? Else
???? ????set New.percent = 100;
???? End If;
End;
推荐阅读
-
MySQL5.7完全卸载步骤详解
-
概述MySQL统计信息
-
mysql 5.7以上版本安装配置方法图文教程(mysql 5.7.12mysql 5.7.13mysql 5.7.14)
-
MySQL常见内存不足启动失败的完美解决方法
-
随机生成八位优惠码并保存至Mysql数据库
-
Mysql5.7中使用group concat函数数据被截断的问题完美解决方法
-
Mysql5.7.17 winx64.zip解压缩版安装配置图文教程
-
MySQL SQL语句分析与查询优化详解
-
Windows 64 位 mysql 5.7以上版本包解压中没有data目录和my-default.ini及服务无法启动的快速解决办法(问题小结)
-
解决mysql ERROR 1045 (28000)-- Access denied for user问题