mysql中存储过程定义、修改和删除的案例

这篇文章给大家分享的是有关mysql中存储过程定义、修改和删除的案例的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。

1.存储过程的分类

  • 系统存储过程

  • 本地存储过程(用户自定义)

  • 临时存储过程(局部【#】、全局【##】临时存储过程)

2.创建存储过程

--选出价格区间的商品信息create procedure sp_goods_price@minprice float ,@maxprice floatas select * from goods 
where price>=@minprice and price <=@maxpricego

执行存储过程: execute sp_goods_price 200 2000

3.修改存储过程

create procedure sp_goods_betw@minprice float =200,@maxprice float=3000as select * from goods 
where price>=@minprice and price <=@maxpricego

4.删除存储过程

drop procedure sp_goods_price

5.查看存储过程

sp_helptext procedureName
sp_help procedureName

6.重命名存储过程

exec sp_rename oldName newName

**局部存储过程

create procedure #sp_goods_betw@minprice float ,@maxprice floatas select * from goods
where price>=@minprice and price <=@maxpricego

**全局存储过程

create procedure ##sp_goods_betw@minprice float ,@maxprice floatas select * from goods 
where price>=@minprice and price <=@maxpricego

**不加缓存的存储过程

with recompile
as select * from goods 
where price>=@minprice and price <=@maxpricego

**加密存储过程

with enctyption
as select * from goods 
where price>=@minprice and price <=@maxpricego

感谢各位的阅读!关于mysql中存储过程定义、修改和删除的案例就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!