Home > Database > Mysql Tutorial > mysql ????????????????????????(???)??????

mysql ????????????????????????(???)??????

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:16:07
Original
1105 people have browsed it

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;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
Mysql cannot start
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template