An identifier is a token used to form a name. An identifier in an SQL statement is either an SQL identifier, a system identifier, or a host identifier.
| Note: | $, @, #, and all other variant characters should not be used in identifiers because the code points used to represent them vary depending on the CCSID of the string in which they are contained. If they are used, unpredictable results may occur. For more information on variant characters, see the book National Language Support, SC41-5101-01. |
There are two types of SQL identifiers: ordinary identifiers and delimited identifiers.
each of which is an uppercase letter, a digit, or the underscore character. Note that ordinary identifiers are converted to uppercase. An ordinary identifier should not be a reserved word.
See Appendix D, Reserved Words for a list of reserved words. If a reserved word is used as an identifier in SQL, it should be specified in uppercase and enclosed within the SQL escape characters.
The escape character is the quotation mark (") except in the following cases where the escape character is the apostrophe ('):
The following characters are not allowed within delimited identifiers:
A system identifier is used to form the name of system objects in OS/400. There are two types of system identifiers: ordinary identifiers and delimited identifiers.
For example, "PRIVILEGES" is in uppercase and the characters within the delimiters form an ordinary identifier; therefore, it has a length of 10 bytes and is a valid system name for a column. On the other hand, "privileges" is in lowercase, has a length of 12 bytes, and is not a valid system name for a column because the bytes required for the delimiters must be included in the length of the identifier.
WKLYSAL WKLY_SAL "WKLY_SAL" "UNION" "wkly_sal"
A host-identifier is a name declared in the host program. The rules for forming a host-identifier are the rules of the host language; except that DBCS characters cannot be used. For example, the rules for forming a host-identifier in a COBOL program are the same as the rules for forming a user-defined word in COBOL. Names beginning with the characters 'SQ'11, 'SQL', 'sql', 'RDI', or 'DSN' should not be used because precompilers generate host variables that begin with these characters.