Home  >  Article  >  Database  >  轻松接触“MySQL”数据库的存储过程_MySQL

轻松接触“MySQL”数据库的存储过程_MySQL

WBOY
WBOYOriginal
2016-06-01 13:56:53851browse

  一.创建存储过程

  1.基本语法:

  create procedure sp_name()

  begin

  .........

  end

  2.参数传递

  二.调用存储过程

  1.基本语法:call sp_name()

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

  三.删除存储过程

  1.基本语法:

  drop procedure sp_name//

  2.注意事项

  (1)不能在一个存储过程中删除另一个存储过程,只能调用另一个存储过程

  四.区块,条件,循环

  1.区块定义,常用

  begin

  ......

  end;

  也可以给区块起别名,如:

  lable:begin

  ...........

  end lable;

  可以用leave lable;跳出区块,执行区块以后的代码

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