sql语句可能包含参数标记。
使用参数标记发出sql语句。
问号(?)代表参数标记。
一个参数标记或一个主变量。
具有参数标记的sql语句。
注意where子句中使用了参数标记。
语句可以有多个参数标记(' ? ')。
本节描述何时使用参数标记,何时使用文本。
This section describes when to use parameter markers and when to use literals.
将应用程序变量绑定到预备语句中的参数标记。
Bind application variables to parameter markers used in a prepared statement.
然而,使用参数标记时,将生成另一个访问计划。
Nevertheless, another access plan is generated when parameter markers are used.
但使用参数标记并不总是比使用文本(显式值)更好。
But using parameter markers is not always better than using literals (explicit values).
首先,需要构造一个具有5个参数标记的动态sql语句。
First, we will compose a dynamic SQL statement with five parameter markers.
如果一个sql语句满足下面所有条件,则使用参数标记。
Parameter markers should be used if all of the following conditions are true for an SQL statement.
DB 2 Command包含8个参数标记符。
使用参数标记,以避免对于每一行都有Prepare成本。
只需在sql语句中使用一次参数标记,然后就可以多次重用。
Use parameter markers to prepare an SQL statement once, and then reuse it many times.
修复由于数据库级别的参数标记使用不充分而导致的性能问题。
Fixing performance issues caused by inadequate use of parameter markers or literals at the database level.
如上节所述,sql语句中的参数标记使用可促进访问计划重用。
As the previous section described, parameter marker usage in SQL statements fosters access plan reuse.
因此,即使使用参数标记,准备阶段的时间和CPU节约也很少。
Therefore, time and CPU savings in the prepare phase is minimal even if parameter markers are used.
编译器选择的默认评估值是用在特殊注册、全局变量或参数标记的。
The default estimates chosen by the compiler are used for the special registers, global variables, or parameter markers.
所有主要数据库接口都提供执行包含参数标记的sql语句的功能。
All major database interfaces offer the capability of executing SQL statements that contain parameter markers.
参数化sql语句包含了变量,也称作参数(或参数标记)。
A parameterized SQL statement contains variables, also known as parameters (or parameter markers).
实现此目的一种简单方式就是在代码中使用字符,而不是使用参数标记。
A simple way to accomplish this is to use literals rather than parameter markers in the code.
REOPT绑定选项将影响其中包含参数标记或主机变量的语句的优化。
The REOPT bind option affects the optimization of statements that contain parameter markers or host variables.
第二个参数标记符用于存放注册的带注释的XML模式的名称。
The second parameter marker holds the name of the registered annotated XML schema.
PDA决定将这些字符串以主机变量还是参数标记符的形式发送。
PDA decides whether the strings can be sent as host variables or parameter markers.
用来检索结果的变量rtnval与using子句中的参数标记有关联。
The variable to retrieve the result, RtnVal, is associated with the parameter marker in the USING clause.
第三个参数标记符用于存放将被分解为字节数组的XML文档的源。
The third parameter marker is to hold the source of the XML document to be shredded in the form of byte array.
让我们再次看看cars表的查询示例,但这次使用参数标记,而不是具体值。
Let's look again at our sample query for the table CARS, but with parameter markers instead of concrete values.
在构造sql语句之后,剩下的步骤就与其他具有参数标记的动态语句完全相同了。
After we compose our SQL statement, all the other steps are the same as for any dynamic statement with parameter markers.
应用推荐