Using the classes and methods of JDBC, you submit SQL statements
as strings. The
character set permitted for strings containing SQL statements is Unicode.
Within these strings, the following rules apply:
- Double quotation marks delimit special identifiers referred to in SQL-92
as delimited identifiers.
- Single quotation marks delimit character strings.
- Within a character string, to represent a single quotation mark or apostrophe,
use two single quotation marks. (In other words, a single quotation mark is
the escape character for a single quotation mark.)
A double quotation
mark does not need an escape character. To represent a double quotation mark,
simply use a double quotation mark. However, note that in a Java
program, a double quotation mark requires the backslash escape character.
-- a single quotation mark is the escape character
-- for a single quotation mark
VALUES 'Joe''s umbrella'
-- in ij, you don't need to escape the double quotation marks
VALUES 'He said, "hello!"'
n = stmt.executeUpdate(
"UPDATE aTable setStringcol = 'He said, \"hello!\"'");
- SQL keywords are case-insensitive. For example, you can type the keyword
SELECT as SELECT, Select, select, or sELECT.
- SQL-92-style identifiers are case-insensitive (see SQL92Identifier),
unless they are delimited.
- Java-style identifiers are always case-sensitive.
- * is a wildcard within a SelectExpression. See The * wildcard. It
can also be the multiplication operator. In all other cases, it is a syntactical
metasymbol that flags items you can repeat 0 or more times.
- % and _ are character wildcards when used within character strings following
a LIKE operator (except when escaped with an escape character). See Boolean expressions.
- Two dashes (--) and a newline character delimit a comment, as per the
SQL-92 standard. The two dashes start the comment and the newline character
ends the comment.