# 8. SQL Reference

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
SQL Reference
Datatypes
User Defined Types
XML Column Type
Identifier Case & Quoting
Wide Character Identifiers
Qualified Names
Literals, Brace Escapes
Strings Numbers ODBC Brace Escapes Hexadecimal Literals Binary Literals
CREATE TABLE Statement
DROP TABLE Statement
CREATE INDEX Statement
DROP INDEX Statement
ALTER TABLE Statement
CREATE VIEW Statement
CREATE XML SCHEMA Statement
DROP XML SCHEMA Statement
Sequence Objects
INSERT Statement
UPDATE Statement
SELECT Statement
COMMIT WORK, ROLLBACK WORK Statement
CHECKPOINT, SHUTDOWN Statement
Stored Procedures as Views & Derived Tables
GRANT, REVOKE Statement
SET Statement
Best Effort Union
Standard and User-Defined Aggregate Functions
Virtuoso SQL Optimization
SQL Inverse Functions
SQL Grammar
Bitmap Indices

## 8.7. Literals, Brace Escapes

### 8.7.1. Strings

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

### 8.7.2. Numbers

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.

### 8.7.3. ODBC Brace Escapes

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

### 8.7.4. Hexadecimal Literals

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>

### 8.7.5. Binary Literals

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