A literal is data whose value cannot be modified within the program. Literals can be numeric literals (which represent numbers) or character string literals, national character string literals, and mixed character string literals (which represent character strings).
Figure 1-4 shows the literals that can be specified in SQL. Table 1-9 shows the notations for literals and the data types that can be interpreted by HiRDB. Table 1-10 lists restrictions on using numeric literals.
Figure 1-4 Specifiable literals
Table 1-9 Notations for literals
Literal | Notation | Data type interpreted by HiRDB | |
---|---|---|---|
Integer1 | [sign]unsigned-integer Examples: -123 45 6789 | Integer represented as a string of unsigned integers with the sign represented by + or -. | INTEGER |
Decimal | [sign]integer-part.fractional-part Examples: 12.3 -456. .789 | An integer part and a fractional part represented as an unsigned integer. Either the integer part or the fractional part may be omitted; the decimal point cannot be omitted. | DECIMAL(m[,n]), where m and n denote numbers of digits. |
Floating-point numeric | mantissaEexponent Examples: 1.0E2 .5E+67 | Either an integer literal or a decimal literal as the mantissa, followed by a 1- to 3-digit integer literal as the exponent. The exponent represents a power of 10. The character E cannot be omitted. | FLOAT |
Character string3 | 'character-string' Examples: 'HITACHI' '88' '''95.7.30' | A character string is expressed by a string of 1-byte characters. To use an single quotation mark in a character string, two single quotation marks in succession must be specified. The maximum length is 32,000 bytes. | VARCHAR(n), where n indicates the length of the character string. 2 |
Hexadecimal character string literal6 | X'hexadecimal-character-string-literal' Examples: X'82A0', X'82a0' | A hexadecimal character string literal is represented with characters 0-9 and A-F (or a-f). The maximum allowable length of a hexadecimal character string literal is 64,000 characters, in a multiple of 2. Two hexadecimal characters make up one byte. | VARCHAR(n) where n is the indicated character string length ![]() |
National character string3, 4, 5 | N'national-character-string' Example: N'SQL-syntax' | A character string is expressed by a string of 2-byte characters. The maximum length is 16,000 characters. | NVARCHAR(n), where n indicates the length of the character string.2 |
Mixed character string3, 4 | M'character-string' Example: M'1996' | A character string is expressed by a string of 1- and 2-byte characters. The maximum length is 32,000 bytes. | MVARCHAR(n), where n indicates the length of the character string.2 |
Table 1-10 Restrictions on use of numeric literals
Numeric literal type | Range | Maximum number of digits (including leading zeros) |
---|---|---|
Integer | -2147483648 to 2147483647 | 10 |
Decimal | ![]() ![]() | 29 |
Floating-point numeric* | Approx. ![]() ![]() ![]() ![]() | Mantissa: 17 Exponent: 3 |