<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head profile="http://internetalchemy.org/2003/02/profile"> <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" /> <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" /> <meta name="dc.subject" content="SQL" /> <meta name="dc.subject" content="SQL Reference" /> <meta name="dc.subject" content="Select" /> <meta name="dc.subject" content="Update" /> <meta name="dc.subject" content="delete" /> <meta name="dc.subject" content="Select Statement" /> <meta name="dc.subject" content="SQL Syntax" /> <meta name="dc.subject" content="Syntax" /> <meta name="dc.title" content="8. SQL Reference" /> <meta name="dc.subject" content="8. SQL Reference" /> <meta name="dc.creator" content="OpenLink Software Documentation Team ; " /> <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" /> <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" /> <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" /> <link rel="parent" href="sqlreference.html" title="Chapter Contents" /> <link rel="prev" href="QUALIFIEDNAMES.html" title="Qualified Names" /> <link rel="next" href="CREATETABLE.html" title="CREATE TABLE Statement" /> <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="doc.css" /> <link rel="stylesheet" type="text/css" href="/doc/translation.css" /> <title>8. SQL Reference</title> <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" /> <meta name="author" content="OpenLink Software Documentation Team ; " /> <meta name="copyright" content="OpenLink Software, 1999 - 2009" /> <meta name="keywords" content="SQL; SQL Reference; Select; Update; delete; Select Statement; SQL Syntax; Syntax; " /> <meta name="GENERATOR" content="OpenLink XSLT Team" /> </head> <body> <div id="header"> <a name="litsbraceescs" /> <img src="../images/misc/logo.jpg" alt="" /> <h1>8. SQL Reference</h1> </div> <div id="navbartop"> <div> <a class="link" href="sqlreference.html">Chapter Contents</a> | <a class="link" href="QUALIFIEDNAMES.html" title="Qualified Names">Prev</a> | <a class="link" href="CREATETABLE.html" title="CREATE TABLE Statement">Next</a> </div> </div> <div id="currenttoc"> <form method="post" action="/doc/adv_search.vspx"> <div class="search">Keyword Search: <br /> <input type="text" name="q" /> <input type="submit" name="go" value="Go" /> </div> </form> <div> <a href="http://www.openlinksw.com/">www.openlinksw.com</a> </div> <div> <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a> </div> <br /> <div> <a href="index.html">Book Home</a> </div> <br /> <div> <a href="contents.html">Contents</a> </div> <div> <a href="preface.html">Preface</a> </div> <br /> <div class="selected"> <a href="sqlreference.html">SQL Reference</a> </div> <br /> <div> <a href="sqlrefDATATYPES.html">Datatypes</a> </div> <div> <a href="udt.html">User Defined Types</a> </div> <div> <a href="sqlrefxmldatatype.html">XML Column Type</a> </div> <div> <a href="catidentifiers.html">Identifier Case & Quoting</a> </div> <div> <a href="wideidentifiers.html">Wide Character Identifiers</a> </div> <div> <a href="QUALIFIEDNAMES.html">Qualified Names</a> </div> <div class="selected"> <a href="litsbraceescs.html">Literals, Brace Escapes</a> <div> <a href="#strings" title="Strings">Strings</a> <a href="#numbers" title="Numbers">Numbers</a> <a href="#odbcbraceesc" title="ODBC Brace Escapes">ODBC Brace Escapes</a> <a href="#sqlrefhexliterals" title="Hexadecimal Literals">Hexadecimal Literals</a> <a href="#sqlrefbinliterals" title="Binary Literals">Binary Literals</a> </div> </div> <div> <a href="CREATETABLE.html">CREATE TABLE Statement</a> </div> <div> <a href="DROPTABLE.html">DROP TABLE Statement</a> </div> <div> <a href="CREATEINDEX.html">CREATE INDEX Statement</a> </div> <div> <a href="DROPINDEX.html">DROP INDEX Statement</a> </div> <div> <a href="ALTERTABLE.html">ALTER TABLE Statement</a> </div> <div> <a href="CREATEVIEW.html">CREATE VIEW Statement</a> </div> <div> <a href="CREATEXMLSCHEMA.html">CREATE XML SCHEMA Statement</a> </div> <div> <a href="DROPXMLSCHEMA.html">DROP XML SCHEMA Statement</a> </div> <div> <a href="sequenceobjects.html">Sequence Objects</a> </div> <div> <a href="insertSTMT.html">INSERT Statement</a> </div> <div> <a href="updatestmt.html">UPDATE Statement</a> </div> <div> <a href="SELECTSTMT.html">SELECT Statement</a> </div> <div> <a href="COMMIT_ROLLBACK.html">COMMIT WORK, ROLLBACK WORK Statement</a> </div> <div> <a href="CHECKPOINT.html">CHECKPOINT, SHUTDOWN Statement</a> </div> <div> <a href="spasviewsandtables.html">Stored Procedures as Views & Derived Tables</a> </div> <div> <a href="GRANT.html">GRANT, REVOKE Statement</a> </div> <div> <a href="SETstmt.html">SET Statement</a> </div> <div> <a href="anytimequeries.html">Anytime Queries</a> </div> <div> <a href="besteffortunion.html">Best Effort Union</a> </div> <div> <a href="aggregates.html">Standard and User-Defined Aggregate Functions</a> </div> <div> <a href="sqloptimizer.html">Virtuoso SQL Optimization</a> </div> <div> <a href="sqlinverse.html">SQL Inverse Functions</a> </div> <div> <a href="GRAMMAR.html">SQL Grammar</a> </div> <div> <a href="BITMAPINDICES.html">Bitmap Indices</a> </div> <div> <a href="transitivityinsQL.html">Transitivity in SQL</a> </div> <div> <a href="sqlreffastphrasematch.html">Fast Phrase Match Processor</a> </div> <br /> </div> <div id="text"> <a name="litsbraceescs" /> <h2>8.7. Literals, Brace Escapes</h2> <a name="strings" /> <h3>8.7.1. Strings</h3> <p> 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. </p> <div> <pre class="screen"> Literal meaning '' <empty> '''' ' '''''' '' '\t\r\n\\' tab, carriage return, newline, backslash '\012' Character 012 octal, i.e. newline </pre> </div> <br /> <a name="numbers" /> <h3>8.7.2. Numbers</h3> <p> An integer constant consist of an optional minus sign followed by decimal digits. Integer literals are of the C type long, 32 bit. </p> <p> 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: </p> <div> <pre class="screen"> 123.456 -16.0 </pre> </div> <p> 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. </p> <p> Integer literals outside of the 32-bit range are interpreted as DECIMAL. </p> <br /> <a name="odbcbraceesc" /> <h3>8.7.3. ODBC Brace Escapes</h3> <p> The Virtuoso SQL parser supports the following ODBC brace escape notations: </p> <div> <pre class="screen"> {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 </pre> </div> <br /> <a name="sqlrefhexliterals" /> <h3>8.7.4. Hexadecimal Literals</h3> <p>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:</p> <div> <pre class="programlisting"> X'beef' - valid 0xbeef - valid X'abeef' - not valid X'0abeef' - valid X'' - not valid </pre> </div> <p> <span class="computeroutput">X'<value>'</span> is equivalent to <span class="computeroutput">0x<value></span> </p> <br /> <a name="sqlrefbinliterals" /> <h3>8.7.5. Binary Literals</h3> <p>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:</p> <div> <pre class="programlisting"> B'1' = 0x01 B'1111' = 0x0F B'111111111' = 0x01FF B'100000001' = 0x0101 B'', X'' and 0x return binary literals. </pre> </div> <br /> <table border="0" width="90%" id="navbarbottom"> <tr> <td align="left" width="33%"> <a href="QUALIFIEDNAMES.html" title="Qualified Names">Previous</a> <br />Qualified Names</td> <td align="center" width="34%"> <a href="sqlreference.html">Chapter Contents</a> </td> <td align="right" width="33%"> <a href="CREATETABLE.html" title="CREATE TABLE Statement">Next</a> <br />CREATE TABLE Statement</td> </tr> </table> </div> <div id="footer"> <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div> <div id="validation"> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /> </a> <a href="http://jigsaw.w3.org/css-validator/"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /> </a> </div> </div> </body> </html>