Capitalization and special characters Using the classes and methods of JDBC, you submit SQL statements to as strings. The character set permitted for strings containing SQL statements is Unicode. Case sensitivity of keywords and identifiers Keywordscase insensitivity of Special charactersescaping in SQL statements Escape characterfor single-quotation mark Stringsdelimited by single quotation marks within SQL statementsUnicode escapessupport for in SQL statementsJava identifierscase sensitivity of within SQL* as wildcard in SQL SELECT% as wildcard in SQL_ as wildcard within SQLWildcards in SQL Comment delimiters within SQL-- (comment delimiters within SQL)

Within these strings, the following rules apply:

  • Double quotation marks delimit special identifiers referred to in SQL 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.

    Example:-- 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-style identifiers are case-insensitive (see ), unless they are delimited.
  • Java-style identifiers are always case-sensitive.
  • * is a wildcard within a selectExpression. See . 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 .
  • Comments can be either single-line or multiline as per the SQL standard. Single-line comments start with two dashes (--) and end with the newline character. Multiline comments are bracketed, start with forward slash star (/*), and end with star forward slash (*/). Note that bracketed comments may be nested. Any text between the starting and ending comment character sequence is ignored.