是否有任何RDBMS提供预准备语句的功能? [英] Does any RDBMS provide the feature of prepared statements?
问题描述
我了解了Java JDBC中预准备语句的概念.因此,我认为预处理语句是JDBC中的概念,而不是RDBMS中的概念.
I learned the concept of prepared statements in JDBC in Java. So I think that prepared statement is a concept in JDBC, but not in RDBMS.
要查看我的猜测是否正确,请问是否有主要的RDBMS以PL/PSM之类的语言(如PL/SQL,PL/pgSQL,MySQL,Transact-SQL)提供预准备语句的功能?
To see whether my guess is right, may I ask whether any major RDBMS provide the feature of prepared statements, in their PL/PSM like languages,such as PL/SQL, PL/pgSQL, MySQL, Transact-SQL?
如果有任何这样的RDBMS,是否以SQL或PL/PSM之类的语言(例如PL/SQL,PL/pgSQL,MySQL,Transact-SQL)提供准备好的语句?
If there is any such RDBMS, is prepared statement provided in SQL, or in PL/PSM like languages,such as PL/SQL, PL/pgSQL, MySQL, Transact-SQL?
我阅读了存储过程与预准备语句之间的区别. >,但是我找不到哪个提供了预处理语句的功能,尽管我认为预处理语句是JDBC中的一个概念,而不是RDBMS中的概念,而存储过程仅是RDBMS中的一个概念.
I read DIfference Between Stored Procedures and Prepared Statements..?, but I can't find which provides the feature of prepared statements, although I think prepared statement is a concept in JDBC not in RDBMS, and stored procedure is a concept in RDBMS only.
推荐答案
每个与SQL兼容的RDBMS的实现都应支持服务器端准备好的语句的API.我想不出一个不支持预备语句的RDBMS.
Every implementation of SQL-compliant RDBMS should support an API for server-side prepared statements. I can't think of one RDBMS that doesn't support prepared statements.
JDBC具有PreparedStatement的类.不同的JDBC驱动程序品牌,其实现方式有所不同,但是我所使用的所有实现都只是委托给RDBMS API. JDBC驱动程序将SQL查询字符串发送到数据库服务器,并且SQL可能包含参数占位符,例如?
(某些品牌(如Oracle)支持命名参数).
JDBC has a class for PreparedStatement. The implementation varies by each brand of JDBC driver, but all those that I have used just delegate to the RDBMS API. The JDBC driver sends an SQL query string to the database server, and the SQL may contain parameter placeholders for example ?
(some brands — like Oracle — support named parameters).
某些数据库实现提供了可用于执行准备好的语句的包或函数,因此您可以在运行时在存储过程中创建查询.
Some database implementations provide packages or functions you can use to execute a prepared statement, so you can create a query at runtime within a stored procedure.
- Oracle: https://docs.oracle .com/cd/A57673_01/DOC/api/doc/PAD18/ch8.htm
- Microsoft SQL Server:
- Oracle: https://docs.oracle.com/cd/A57673_01/DOC/api/doc/PAD18/ch8.htm
- Microsoft SQL Server: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-prepare-transact-sql?view=sql-server-2017
某些数据库实现还支持您可以作为查询调用的PREPARE
和EXECUTE
语句.这样,您就可以在存储过程或SQL脚本中使用准备好的语句.
Some database implementations also support PREPARE
and EXECUTE
statements that you can call as a query. This allows you to use prepared statements in a stored procedure or an SQL script.
- MySQL: https://dev .mysql.com/doc/refman/8.0/en/sql-syntax-prepared-statements.html
- PostgreSQL: https://www.postgresql.org/docs /10/static/sql-prepare.html
- MySQL: https://dev.mysql.com/doc/refman/8.0/en/sql-syntax-prepared-statements.html
- PostgreSQL: https://www.postgresql.org/docs/10/static/sql-prepare.html
这篇关于是否有任何RDBMS提供预准备语句的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!