MySQL5创建存储过程的示例

很文博客hinven.com 数据库评论48字数 553阅读模式
广告也精彩

存储过程可以一次执行多个sql语句,所以php只连接数据库一次就能查询多个语句;不过要返回多个结果集就必须用mysqli扩展来查询,否则会提示错误can't return a result set in the given context

1 用mysql客户端登入文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

2 选择数据库文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

mysql>use test文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

3 查询当前数据库有哪些存储过程文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

mysql>show procedure status where Db='test'文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

4 创建一个简单的存储过程文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

mysql>create procedure hi() select 'hello';文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/54569.html

5 存储过程创建完毕,看怎么调用它

mysql>call hi();

显示结果  mysql> call hi();
+-------+
| hello |
+-------+
| hello |
+-------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)

6 一个简单的储存过程就成功了,这只是一个演示,存储过程可以一次执行多个sql语句,所以php只连接数据库一次就能查询多个语句;不过要返回多个结果集就必须用mysqli扩展来查询,否则会提示错误can't return a result set in the given context

所以要使用这些新功能,最好适应使用mysqli的php扩展库。

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
  • Mysql5
  • 创建存储过程
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证