Tokens
Tokens are the basic syntactical units of SQL. A token is a sequence of one or more characters.
A token cannot contain blank characters, unless it is a string constant or a delimited identifier, which may contain blanks.
Tokens are classified as ordinary or delimiter:
- An ordinary token is a numeric constant, an ordinary identifier,
a host identifier, or a keyword. Examples
1 .1 +2 SELECT E 3
- A delimiter token is a string constant, a delimited identifier,
an operator symbol, or any of the special characters shown in the
syntax diagrams. A question mark is also a delimiter token when it
serves as a parameter marker. Examples
, 'string' "fld1" = .
Spaces: A space is a sequence of one or more blank characters. Tokens other than string constants and delimited identifiers must not include a space. Any token may be followed by a space. Every ordinary token must be followed by a space or a delimiter token if allowed by the syntax.
Comments: SQL comments are either bracketed (introduced by /* and end with */) or simple (introduced by two consecutive hyphens and end with the end of line). Static SQL statements can include host language comments or SQL comments. Comments can be specified wherever a space can be specified, except within a delimiter token or between the keywords EXEC and SQL.
select * from EMPLOYEE where lastname = 'Smith';
is
equivalent, after folding, to: SELECT * FROM EMPLOYEE WHERE LASTNAME = 'Smith';
Multi-byte alphabetic letters are not folded to uppercase. Single-byte characters (a to z) are folded to uppercase.
- A character is folded to uppercase, if applicable, if the uppercase character in UTF-8 has the same length as the lowercase character in UTF-8. For example, the Turkish lowercase dotless 'i' is not folded, because in UTF-8, that character has the value X'C4B1', but the uppercase dotless 'I' has the value X'49'.
- The folding is done in a locale-insensitive manner. For example, the Turkish lowercase dotted 'i' is folded to the English uppercase (dotless) 'I'.
- Both halfwidth and fullwidth alphabetic letters are folded to uppercase. For example, the fullwidth lowercase 'a' (U+FF41) is folded to the fullwidth uppercase 'A' (U+FF21).