存储过程和准备好的语句之间的区别? [英] DIfference Between Stored Procedures and Prepared Statements?

查看:56
本文介绍了存储过程和准备好的语句之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储过程和预备语句之间有什么区别?哪个更好,为什么...!我试图在Google上搜索它,但没有更好的文章...

What is the difference between Stored Procedures and Prepared Statements... And which one is better and why...!! I was trying to google it but haven't got any better article...

推荐答案

存储过程是PL/SQL语言中的一系列指令.是由某些DBMS实现的一种编程语言,它使您可以存储经常应用于模型的查询序列,并与应用程序层共享处理负载.

Stored procedures are a sequence of instructions in PL/SQL language. Is a programming language implemented by some DBMS, that lets you store sequences of queries frequently applied to your model, and share the processing load with the application layer.

准备的语句是使用占位符而不是实际值编写的查询.您编写查询,DBMS只会对其进行一次编译,然后只需将要传递的值放入占位符即可.使用准备好的语句的优点是可以大大提高性能,并保护应用程序免受SQL注入的侵害.

Prepared statements are queries written with placeholders instead of actual values. You write the query and it is compiled just once by the DBMS, and then you just pass values to place into the placeholders. The advantage of using prepared statements is that you enhance the performance considerably, and protect your applications from SQL Injection.

区别在于您不能存储准备好的语句.每次需要执行一个任务时,都必须准备"它们.另一方面,可以存储与模式相关联的存储过程,但是您需要知道PL/SQL才能编写它们.

The difference is you cant store prepared statements. You must "prepare" them every time you need to execute one. Stored procedures, on the other hand, can be stored, associated to a schema, but you need to know PL/SQL to write them.

您必须检查您的DBMS是否支持它们.

You must check if your DBMS supports them.

这两种都是非常有用的工具,您可能需要结合使用.

Both are very usefull tools, you might want to combine.

希望这个简短的说明对您有用!

Hope this short explanation to be useful to you!

这篇关于存储过程和准备好的语句之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆