String literals are delimited with single quotes. A double single quote is an escape notation for a single quote character inside a string literal. Additionally, standard C language escapes are supported. Support of C escapes can be turned off for compatibility with other SQL databases by using the SQL_NO_CHAR_C_ESCAPE option in the configuration file or as an ODBC connection option.
Literal meaning '' <empty> '''' ' '''''' '' '\t\r\n\\' tab, carriage return, newline, backslash '\012' Character 012 octal, i.e. newline
An integer constant consist of an optional minus sign followed by decimal digits. Integer literals are of the C type long, 32 bit.
Numeric literals with a decimal point literal are internally of the DECIMAL SQL type, a variable length decimal floating point type. The Following are examples of decimal literals:
123.456 -16.0
Numeric literals which specify an exponent, e.g. 1.2e11 or 2e-3 are read as C doubles, (64 bit IEEE binary floating point). This is potentially less precise than the DECIMAL SQL type.
Integer literals outside of the 32-bit range are interpreted as DECIMAL.
The Virtuoso SQL parser supports the following ODBC brace escape notations:
{fn function (argument, ..) } fm (arguments .) call procedure a1, ... } {d 'yyyy.mm.dd'} {t 'hh:mm.ss' } {ts 'yyyy.mm.dd hh:mm.s fraction' } {oj } -- outer join
Hexadecimal values can be specified literally in two ways, prefixing the plain value with '0x' or enclosed with single quotes prefixed with 'X'. The case is not important. Hex characters should always be pairs, representing a single byte, and should be at least on pair. Here are some examples:
X'beef' - valid 0xbeef - valid X'abeef' - not valid X'0abeef' - valid X'' - not valid
X'<value>' is equivalent to 0x<value>
Binary strings can be specified as literals prefixed with 'B' and enclosed with single quotes. The string should not be empty and should contain only 1's or 0's. Binary strings are read from the end to beginning forming bytes on each 8-th bit:
B'1' = 0x01 B'1111' = 0x0F B'111111111' = 0x01FF B'100000001' = 0x0101 B'', X'' and 0x return binary literals.
Previous
Qualified Names |
Chapter Contents |
Next
CREATE TABLE Statement |