Home >Database >Mysql Tutorial >mysql之存储过程_MySQL

mysql之存储过程_MySQL

WBOY
WBOYOriginal
2016-06-01 13:30:331181browse

bitsCN.com

mysql之存储过程

 

存储过程

注意:存储过程名称后面必须加括号,哪怕该存储过程没有参数传递

 

1.基本语法:

create procedure sp_name()begin.........end修改命令结束符delimiter $

 

 

例:

创建procedurecreate procedure myproce()beginINSERT INTO main (num) VALUES (15);end;调用存储过程:call myproce();查看数据库中所有的存储过程:show procedure status;查看存储过程的创建代码show create procedure proc_name;删除存储过程drop procedure proc_name

 

 

 

2.基本语法:

 

CREATE FUNCTION hello () RETURNS .......RETURN 

 

 

例:

创建functionCREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)RETURN CONCAT('Hello, ',s,'!');调用functionselect hello('world');查看存储过程函数的创建代码show create function func_name;删除drop function func_name;

 


bitsCN.com
Statement:
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