使用 SQL 转义序列Using SQL escape sequences
08/12/2019
本文内容
按照 JDBC API 的定义,Microsoft JDBC Driver for SQL ServerMicrosoft JDBC Driver for SQL Server 支持使用 SQL 转义序列。The Microsoft JDBC Driver for SQL ServerMicrosoft JDBC Driver for SQL Server supports the use of SQL escape sequences, as defined by the JDBC API. 转义序列用于 SQL 语句内,以告诉驱动程序应以不同的方式处理 SQL 字符串的转义部分。Escape sequences are used within an SQL statement to tell the driver that the escaped part of the SQL string should be handled differently. 当 JDBC 驱动程序处理 SQL 字符串的转义部分时,它会将字符串的这一部分转换为 SQL Server 可以理解的 SQL 代码。When the JDBC driver processes the escaped part of an SQL string, it translates that part of the string into SQL code that SQL Server understands.
JDBC API 需要五种类型的转义序列,JDBC 驱动程序支持所有这些转义序列:There are five types of escape sequences that the JDBC API requires, and all are supported by the JDBC driver:
LIKE 通配符文本LIKE wildcard literals
函数处理Function handling
日期和时间文本Date and time literals
存储过程调用Stored procedure calls
外部联接Outer joins
限制转义语法Limit escape syntax
JDBC 驱动程序使用的转义序列语法如下所示:The escape sequence syntax used by the JDBC driver is the following:
{keyword ...parameters...}
备注
SQL 转义处理对于 JDBC 驱动程序始终是打开的。SQL escape processing is always turned on for the JDBC driver.
以下各部分介绍五种类型的转义序列以及 JDBC 驱动程序如何支持它们。The following sections describe the five types of escape sequences and how they are supported by the JDBC driver.
LIKE 通配符文本LIKE wildcard literals
JDBC 驱动程序支持 {escape 'escape character'} 语法,以便将 LIKE 子句通配符用作文本。The JDB