~ubuntu-branches/ubuntu/maverick/hsqldb/maverick

« back to all changes in this revision

Viewing changes to doc/guide/guide.html

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-09-26 11:47:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060926114749-3jd0utm7w21x1iqt
Tags: 1.8.0.5-2ubuntu1
* Synchronise with Debian unstable; remaining changes:
  - build using java-gcj-compat.
* libhsqldb-java: Add gij as alternative dependency.
* Build a libhsqldb-java-gcj package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
            </a></span></dt><dt><span class="section"><a href="#N10780">Init script Setup Procedure</a></span></dt><dt><span class="section"><a href="#initscriptTrouble-section">
8
8
                Troubleshooting the Init Script
9
9
            </a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#advanced-chapter">4. Advanced Topics</a></span></dt><dd><dl><dt><span class="section"><a href="#N108C9">Purpose</a></span></dt><dt><span class="section"><a href="#N108D2">Connections</a></span></dt><dd><dl><dt><span class="section"><a href="#N109E6">Connection properties</a></span></dt></dl></dd><dt><span class="section"><a href="#N10A68">Properties Files</a></span></dt><dd><dl><dt><span class="section"><a href="#N10AC1">Server and Web Server Properties</a></span></dt><dt><span class="section"><a href="#N10BBC">Starting a Server from your application</a></span></dt><dt><span class="section"><a href="#N10BCF">Individual Database Properties</a></span></dt></dl></dd><dt><span class="section"><a href="#N10D67">SQL Commands for Database Properties</a></span></dt></dl></dd><dt><span class="chapter"><a href="#N10DAC">5. Deployment Issues</a></span></dt><dd><dl><dt><span class="section"><a href="#N10DCD">Purpose</a></span></dt><dt><span class="section"><a href="#N10DD6">Mode of Operation and Tables</a></span></dt><dd><dl><dt><span class="section"><a href="#N10DDB">Mode of Operation</a></span></dt><dt><span class="section"><a href="#N10DED">Tables</a></span></dt><dt><span class="section"><a href="#N10E04">Large Objects</a></span></dt><dt><span class="section"><a href="#N10E15">Deployment context</a></span></dt></dl></dd><dt><span class="section"><a href="#N10E21">Memory and Disk Use</a></span></dt><dd><dl><dt><span class="section"><a href="#N10E3E">Cache Memory Allocation</a></span></dt></dl></dd><dt><span class="section"><a href="#N10E5F">Managing Database Connections</a></span></dt><dt><span class="section"><a href="#N10E76">Upgrading Databases</a></span></dt><dd><dl><dt><span class="section"><a href="#upgrade_via_script-section">Upgrading Using the SCRIPT
10
 
      Command</a></span></dt><dt><span class="section"><a href="#N10ECE">Manual Changes to the .script File</a></span></dt></dl></dd><dt><span class="section"><a href="#N10F02">Backing Up Databases</a></span></dt></dl></dd><dt><span class="chapter"><a href="#texttables-chapter">6. Text Tables</a></span></dt><dd><dl><dt><span class="section"><a href="#N10F46">The Implementation</a></span></dt><dd><dl><dt><span class="section"><a href="#N10F49">Definition of Tables</a></span></dt><dt><span class="section"><a href="#N10F58">Scope and Reassignment</a></span></dt><dt><span class="section"><a href="#N10F73">Null Values in Columns of Text Tables</a></span></dt><dt><span class="section"><a href="#N10F7F">Configuration</a></span></dt></dl></dd><dt><span class="section"><a href="#N11030">Text File Issues</a></span></dt><dt><span class="section"><a href="#N11055">Text File Global Properties</a></span></dt><dt><span class="section"><a href="#N11093">Importing from a Text Table file</a></span></dt></dl></dd><dt><span class="chapter"><a href="#tls-chapter">7. TLS</a></span></dt><dd><dl><dt><span class="section"><a href="#N110D1">Requirements</a></span></dt><dt><span class="section"><a href="#N110EE">Encrypting your JDBC connection</a></span></dt><dd><dl><dt><span class="section"><a href="#N110F3">Client-Side</a></span></dt><dt><span class="section"><a href="#N1115E">Server-Side</a></span></dt></dl></dd><dt><span class="section"><a href="#jsse-section">JSSE</a></span></dt><dt><span class="section"><a href="#privatekey-section">Making a Private-key Keystore</a></span></dt><dd><dl><dt><span class="section"><a href="#N1119A">CA-Signed Cert</a></span></dt><dt><span class="section"><a href="#N111C3">Non-CA-Signed Cert</a></span></dt></dl></dd><dt><span class="section"><a href="#N111D0">Automatic Server or WebServer startup on UNIX</a></span></dt></dl></dd><dt><span class="chapter"><a href="#sqltool-chapter">8. SqlTool</a></span></dt><dd><dl><dt><span class="section"><a href="#N1120E">Purpose</a></span></dt><dd><dl><dt><span class="section"><a href="#N11217">Recent changes</a></span></dt></dl></dd><dt><span class="section"><a href="#baremin-section">The Bare Minimum</a></span></dt><dd><dl><dt><span class="section"><a href="#N112EC">Non-displayable Types</a></span></dt><dt><span class="section"><a href="#N11311">Desktop shortcuts</a></span></dt><dt><span class="section"><a href="#N1138F">Loading sample data</a></span></dt></dl></dd><dt><span class="section"><a href="#auth-section">RC File Authentication Setup</a></span></dt><dt><span class="section"><a href="#N11428">
 
10
      Command</a></span></dt><dt><span class="section"><a href="#N10ECE">Manual Changes to the .script File</a></span></dt></dl></dd><dt><span class="section"><a href="#N10F02">Backing Up Databases</a></span></dt></dl></dd><dt><span class="chapter"><a href="#texttables-chapter">6. Text Tables</a></span></dt><dd><dl><dt><span class="section"><a href="#N10F46">The Implementation</a></span></dt><dd><dl><dt><span class="section"><a href="#N10F49">Definition of Tables</a></span></dt><dt><span class="section"><a href="#N10F58">Scope and Reassignment</a></span></dt><dt><span class="section"><a href="#N10F73">Null Values in Columns of Text Tables</a></span></dt><dt><span class="section"><a href="#N10F7F">Configuration</a></span></dt></dl></dd><dt><span class="section"><a href="#N11030">Text File Issues</a></span></dt><dt><span class="section"><a href="#N11055">Text File Global Properties</a></span></dt><dt><span class="section"><a href="#N11093">Importing from a Text Table file</a></span></dt></dl></dd><dt><span class="chapter"><a href="#tls-chapter">7. TLS</a></span></dt><dd><dl><dt><span class="section"><a href="#N110D1">Requirements</a></span></dt><dt><span class="section"><a href="#N110EE">Encrypting your JDBC connection</a></span></dt><dd><dl><dt><span class="section"><a href="#N110F3">Client-Side</a></span></dt><dt><span class="section"><a href="#N1115E">Server-Side</a></span></dt></dl></dd><dt><span class="section"><a href="#jsse-section">JSSE</a></span></dt><dt><span class="section"><a href="#privatekey-section">Making a Private-key Keystore</a></span></dt><dd><dl><dt><span class="section"><a href="#N1119A">CA-Signed Cert</a></span></dt><dt><span class="section"><a href="#N111C3">Non-CA-Signed Cert</a></span></dt></dl></dd><dt><span class="section"><a href="#N111D0">Automatic Server or WebServer startup on UNIX</a></span></dt></dl></dd><dt><span class="chapter"><a href="#sqltool-chapter">8. SqlTool</a></span></dt><dd><dl><dt><span class="section"><a href="#N11219">Purpose</a></span></dt><dd><dl><dt><span class="section"><a href="#N11222">Recent changes</a></span></dt></dl></dd><dt><span class="section"><a href="#baremin-section">The Bare Minimum</a></span></dt><dd><dl><dt><span class="section"><a href="#N112DD">Non-displayable Types</a></span></dt><dt><span class="section"><a href="#N11302">Desktop shortcuts</a></span></dt><dt><span class="section"><a href="#N11380">Loading sample data</a></span></dt></dl></dd><dt><span class="section"><a href="#auth-section">RC File Authentication Setup</a></span></dt><dt><span class="section"><a href="#ilauth-section">Using Inline RC Authentication</a></span></dt><dt><span class="section"><a href="#N11461">
11
11
            Using the current version of SqlTool with an older HSQLDB
12
12
            distribution.
13
 
        </a></span></dt><dt><span class="section"><a href="#int-section">Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#N114AE">Command Types</a></span></dt><dt><span class="section"><a href="#N11502">Special Commands</a></span></dt><dt><span class="section"><a href="#N115B6">Buffer Commands</a></span></dt><dt><span class="section"><a href="#interactive_pl_commands-section">PL Commands</a></span></dt><dt><span class="section"><a href="#binary_files-section">
14
 
                Storing and retrieving binary files</a></span></dt><dt><span class="section"><a href="#N116DA">SQL History</a></span></dt><dt><span class="section"><a href="#N116E9">Shell scripting and command-line piping</a></span></dt><dt><span class="section"><a href="#N116F2">Emulating Non-Interactive mode</a></span></dt></dl></dd><dt><span class="section"><a href="#nonint-section">Non-Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#sqlswitch-section">Giving SQL on the Command Line</a></span></dt><dt><span class="section"><a href="#N11755">SQL Files</a></span></dt><dt><span class="section"><a href="#scripting-section">Piping and shell scripting</a></span></dt><dt><span class="section"><a href="#N117BD">Optimally Compatible SQL Files</a></span></dt><dt><span class="section"><a href="#N117D0">Comments</a></span></dt><dt><span class="section"><a href="#N117F3">Special Commands and Buffer Commands in SQL Files</a></span></dt><dt><span class="section"><a href="#N1185E">Automation</a></span></dt><dt><span class="section"><a href="#N11869">Getting Interactive Functionality with SQL Files</a></span></dt><dt><span class="section"><a href="#charencoding-section">
15
 
                Character Encoding</a></span></dt></dl></dd><dt><span class="section"><a href="#report-section">Generating Text or HTML Reports</a></span></dt><dt><span class="section"><a href="#pl-section">SqlTool Procedural Language</a></span></dt><dd><dl><dt><span class="section"><a href="#N118F8">Variables</a></span></dt><dt><span class="section"><a href="#pl_alias-section">PL Aliases</a></span></dt><dt><span class="section"><a href="#N11976">Logical Expressions</a></span></dt><dt><span class="section"><a href="#N119EF">Flow Control</a></span></dt></dl></dd><dt><span class="section"><a href="#chunk-section">Chunking</a></span></dt><dd><dl><dt><span class="section"><a href="#N11A4D">Why?</a></span></dt><dt><span class="section"><a href="#N11A54">How?</a></span></dt></dl></dd><dt><span class="section"><a href="#raw-section">Raw Mode</a></span></dt><dt><span class="section"><a href="#N11A81">PL/SQL</a></span></dt><dt><span class="section"><a href="#N11AA2">Using hsqltool.jar and hsqldbutil.jar</a></span></dt><dt><span class="section"><a href="#N11AFB">Unit Testing SqlTool</a></span></dt></dl></dd><dt><span class="chapter"><a href="#sqlsyntax-chapter">9. SQL Syntax</a></span></dt><dd><dl><dt><span class="section"><a href="#N11B4F">Notational Conventions Used in this Chapter</a></span></dt><dt><span class="section"><a href="#N11B6C">SQL Commands</a></span></dt><dd><dl><dt><span class="section"><a href="#alter_index-section">ALTER INDEX</a></span></dt><dt><span class="section"><a href="#alter_sequence-section">ALTER SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11B8B">ALTER SCHEMA</a></span></dt><dt><span class="section"><a href="#alter_table-section">ALTER TABLE</a></span></dt><dt><span class="section"><a href="#alter_user-section">ALTER USER</a></span></dt><dt><span class="section"><a href="#call-section">CALL</a></span></dt><dt><span class="section"><a href="#checkpoint-section">CHECKPOINT</a></span></dt><dt><span class="section"><a href="#commit-section">COMMIT</a></span></dt><dt><span class="section"><a href="#connect-section">CONNECT</a></span></dt><dt><span class="section"><a href="#create_alias-section">CREATE ALIAS</a></span></dt><dt><span class="section"><a href="#create_index-section">CREATE INDEX</a></span></dt><dt><span class="section"><a href="#create_role-section">CREATE ROLE</a></span></dt><dt><span class="section"><a href="#N11CA5">CREATE SCHEMA</a></span></dt><dt><span class="section"><a href="#create_sequence-section">CREATE SEQUENCE</a></span></dt><dt><span class="section"><a href="#create_table-section">CREATE TABLE</a></span></dt><dt><span class="section"><a href="#create_trigger-section">CREATE TRIGGER</a></span></dt><dt><span class="section"><a href="#create_user-section">CREATE USER</a></span></dt><dt><span class="section"><a href="#create_view-section">CREATE VIEW</a></span></dt><dt><span class="section"><a href="#delete-section">DELETE</a></span></dt><dt><span class="section"><a href="#disconnect-section">DISCONNECT</a></span></dt><dt><span class="section"><a href="#drop_index-section">DROP INDEX</a></span></dt><dt><span class="section"><a href="#N11E14">DROP ROLE</a></span></dt><dt><span class="section"><a href="#drop_sequence-section">DROP SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11E2E">DROP SCHEMA</a></span></dt><dt><span class="section"><a href="#drop_table-section">DROP TABLE</a></span></dt><dt><span class="section"><a href="#drop_trigger-section">DROP TRIGGER</a></span></dt><dt><span class="section"><a href="#drop_user-section">DROP USER</a></span></dt><dt><span class="section"><a href="#drop_view-section">DROP VIEW</a></span></dt><dt><span class="section"><a href="#explain-section">EXPLAIN PLAN</a></span></dt><dt><span class="section"><a href="#grant-section">GRANT</a></span></dt><dt><span class="section"><a href="#insert-section">INSERT</a></span></dt><dt><span class="section"><a href="#revoke-section">REVOKE</a></span></dt><dt><span class="section"><a href="#rollback-section">ROLLBACK</a></span></dt><dt><span class="section"><a href="#savepoint-section">SAVEPOINT</a></span></dt><dt><span class="section"><a href="#script-section">SCRIPT</a></span></dt><dt><span class="section"><a href="#select-section">SELECT</a></span></dt><dt><span class="section"><a href="#set_autocommit-section">SET AUTOCOMMIT</a></span></dt><dt><span class="section"><a href="#collation-section">SET DATABASE COLLATION</a></span></dt><dt><span class="section"><a href="#N11FBD">SET CHECKPOINT DEFRAG</a></span></dt><dt><span class="section"><a href="#set_ignorecase-section">SET IGNORECASE</a></span></dt><dt><span class="section"><a href="#set_logsize-section">SET LOGSIZE</a></span></dt><dt><span class="section"><a href="#set_password-section">SET PASSWORD</a></span></dt><dt><span class="section"><a href="#set_property-section">SET PROPERTY</a></span></dt><dt><span class="section"><a href="#set_refint-section">SET REFERENTIAL INTEGRITY</a></span></dt><dt><span class="section"><a href="#N1201E">SET SCHEMA</a></span></dt><dt><span class="section"><a href="#set_scriptformat-section">SET SCRIPTFORMAT</a></span></dt><dt><span class="section"><a href="#set_table_index-section">SET TABLE INDEX</a></span></dt><dt><span class="section"><a href="#set_table_readonly-section">SET TABLE READONLY</a></span></dt><dt><span class="section"><a href="#set_table_source-section">SET TABLE SOURCE</a></span></dt><dt><span class="section"><a href="#set_write_delay-section">SET WRITE DELAY</a></span></dt><dt><span class="section"><a href="#shutdown-section">SHUTDOWN</a></span></dt><dt><span class="section"><a href="#update-section">UPDATE</a></span></dt></dl></dd><dt><span class="section"><a href="#datatypes-section">Data Types</a></span></dt><dt><span class="section"><a href="#N12234">SQL Comments</a></span></dt><dt><span class="section"><a href="#stored-section">Stored Procedures / Functions</a></span></dt><dt><span class="section"><a href="#N12265">Built-in Functions and Stored Procedures</a></span></dt><dt><span class="section"><a href="#expression-section">SQL Expression</a></span></dt></dl></dd><dt><span class="appendix"><a href="#building-appendix">A. Building HSQLDB</a></span></dt><dd><dl><dt><span class="section"><a href="#N1256A">Purpose</a></span></dt><dt><span class="section"><a href="#N12573">Building with Ant</a></span></dt><dd><dl><dt><span class="section"><a href="#N1257A">Obtaining Ant</a></span></dt><dt><span class="section"><a href="#N12592">Building Hsqldb with Ant</a></span></dt></dl></dd><dt><span class="section"><a href="#N12641">Building with DOS Batch Files</a></span></dt><dt><span class="section"><a href="#N1265A">Hsqldb CodeSwitcher</a></span></dt><dt><span class="section"><a href="#N12686">Building documentation</a></span></dt></dl></dd><dt><span class="appendix"><a href="#firstclient-appendix">B. First JDBC Client Example</a></span></dt><dt><span class="appendix"><a href="#N126E1">C. Hsqldb Database Files and Recovery</a></span></dt><dd><dl><dt><span class="section"><a href="#N126F8"></a></span></dt><dt><span class="section"><a href="#N12728">States</a></span></dt><dd><dl><dt><span class="section"><a href="#N1272B"></a></span></dt><dt><span class="section"><a href="#N1275A"></a></span></dt><dt><span class="section"><a href="#N12789"></a></span></dt></dl></dd><dt><span class="section"><a href="#N127BB">Procedures</a></span></dt><dd><dl><dt><span class="section"><a href="#N127C0">Clean Shutdown</a></span></dt><dt><span class="section"><a href="#N1281A">Startup</a></span></dt><dt><span class="section"><a href="#N1286C">Repair</a></span></dt></dl></dd></dl></dd><dt><span class="appendix"><a href="#N128B2">D. Running Hsqldb with OpenOffice.org 1.1.x</a></span></dt><dd><dl><dt><span class="section"><a href="#N128D2">Introduction</a></span></dt><dt><span class="section"><a href="#N128DB">Installing</a></span></dt><dt><span class="section"><a href="#N128E0">Setting up OpenOffice.org</a></span></dt><dd><dl><dt><span class="section"><a href="#N128F2">On Windows</a></span></dt><dt><span class="section"><a href="#N12905">On Linux</a></span></dt></dl></dd></dl></dd><dt><span class="appendix"><a href="#N12925">E. Hsqldb Test Utility</a></span></dt><dt><span class="appendix"><a href="#N1299B">F. Database Manager</a></span></dt><dd><dl><dt><span class="section"><a href="#N129C4">Brief Introduction</a></span></dt><dt><span class="section"><a href="#N129EE">Auto tree-update</a></span></dt><dt><span class="section"><a href="#N12A05">Automatic Connection</a></span></dt><dt><span class="section"><a href="#N12A13">RC File</a></span></dt><dt><span class="section"><a href="#N12A38">Using the current DatabaseManagers with an older HSQLDB
16
 
    distribution.</a></span></dt><dt><span class="section"><a href="#N12A6A">DatabaseManagerSwing as an Applet</a></span></dt></dl></dd><dt><span class="appendix"><a href="#N12AC8">G. Transfer Tool</a></span></dt><dd><dl><dt><span class="section"><a href="#N12AE5">Brief Introduction</a></span></dt></dl></dd></dl></div><div class="list-of-tables"><p><b>List of Tables</b></p><dl><dt>1. <a href="#N1004D">Alternate formats of this document</a></dt><dt>4.1. <a href="#N108EC">Hsqldb URL Components</a></dt><dt>4.2. <a href="#N109FA">Connection Properties</a></dt><dt>4.3. <a href="#N10A81">Hsqldb Server Properties Files</a></dt><dt>4.4. <a href="#N10ACE">Property File Properties</a></dt><dt>4.5. <a href="#N10B3C">Server Property File Properties</a></dt><dt>4.6. <a href="#N10B6F">WebServer Property File Properties</a></dt><dt>4.7. <a href="#N10BEF">Database-specific Property File Properties</a></dt><dt>4.8. <a href="#N10D6C">SQL command properties</a></dt><dt>9.1. <a href="#N12142">Data Types</a></dt></dl></div><div class="list-of-examples"><p><b>List of Examples</b></p><dl><dt>1.1. <a href="#N1018D">Java code to connect to the local Server above</a></dt><dt>2.1. <a href="#N102E6">Column values which satisfy a 2-column UNIQUE
17
 
        constraint</a></dt><dt>2.2. <a href="#N103AB">Query comparison</a></dt><dt>2.3. <a href="#N104F2">Numbering returned rows of a SELECT in sequential order</a></dt><dt>3.1. <a href="#N107DB">server.properties fragment</a></dt><dt>3.2. <a href="#N107EE">example sqltool.rc stanza</a></dt><dt>7.1. <a href="#N11110">Exporting certificate from the server's keystore</a></dt><dt>7.2. <a href="#N11125">Adding a certificate to the client keystore</a></dt><dt>7.3. <a href="#N11134">Specifying your own trust store to a JDBC client</a></dt><dt>7.4. <a href="#N1116A">Running an Hsqldb server with TLS encryption</a></dt><dt>7.5. <a href="#N111AA">Getting a pem-style private key into a JKS keystore</a></dt><dt>8.1. <a href="#N113BD">Sample RC File</a></dt><dt>8.2. <a href="#alias-example">Defining and using a PL alias (PL variable)</a></dt><dt>8.3. <a href="#N116C8">Inserting binary data into database from a file</a></dt><dt>8.4. <a href="#N116CE">Downloading binary data from database to a file</a></dt><dt>8.5. <a href="#N117AD">Piping input into SqlTool</a></dt><dt>8.6. <a href="#N117D9">Valid comment example</a></dt><dt>8.7. <a href="#N117E1">Invalid comment example</a></dt><dt>8.8. <a href="#N11968">Simple SQL file using PL</a></dt><dt>8.9. <a href="#N11A31">SQL File showing use of most PL features</a></dt><dt>8.10. <a href="#N11A46">Single-line chunking example</a></dt><dt>8.11. <a href="#N11A59">Multi-line chunking example</a></dt><dt>8.12. <a href="#N11A78">Raw Mode example</a></dt><dt>8.13. <a href="#N11A9B">PL/SQL Example</a></dt><dt>A.1. <a href="#N12633">Buiding the standard Hsqldb jar file with Ant</a></dt><dt>A.2. <a href="#N12663">Example source code before CodeSwitcher is run</a></dt><dt>A.3. <a href="#N1266B">CodeSwitcher command line invocation</a></dt><dt>A.4. <a href="#N12677">Source code after CodeSwitcher processing</a></dt><dt>A.5. <a href="#N12698">Building HTML User Guides</a></dt><dt>A.6. <a href="#N126A9">Building User Guides in all formats</a></dt><dt>B.1. <a href="#N126DA">JDBC Client source code example</a></dt></dl></div><div class="preface" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N10030"></a>Introduction</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1003A">Available formats for this document</a></span></dt></dl></div><p>
 
13
        </a></span></dt><dt><span class="section"><a href="#int-section">Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#N114E7">Command Types</a></span></dt><dt><span class="section"><a href="#N11538">Special Commands</a></span></dt><dt><span class="section"><a href="#N115E6">Buffer Commands</a></span></dt><dt><span class="section"><a href="#interactive_pl_commands-section">PL Commands</a></span></dt><dt><span class="section"><a href="#binary_files-section">
 
14
                Storing and retrieving binary files</a></span></dt><dt><span class="section"><a href="#N1170A">SQL History</a></span></dt><dt><span class="section"><a href="#N11719">Shell scripting and command-line piping</a></span></dt><dt><span class="section"><a href="#N11722">Emulating Non-Interactive mode</a></span></dt></dl></dd><dt><span class="section"><a href="#nonint-section">Non-Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#sqlswitch-section">Giving SQL on the Command Line</a></span></dt><dt><span class="section"><a href="#N1177D">SQL Files</a></span></dt><dt><span class="section"><a href="#scripting-section">Piping and shell scripting</a></span></dt><dt><span class="section"><a href="#N117E5">Optimally Compatible SQL Files</a></span></dt><dt><span class="section"><a href="#N117F8">Comments</a></span></dt><dt><span class="section"><a href="#N1181B">Special Commands and Buffer Commands in SQL Files</a></span></dt><dt><span class="section"><a href="#N11880">Automation</a></span></dt><dt><span class="section"><a href="#N1188B">Getting Interactive Functionality with SQL Files</a></span></dt><dt><span class="section"><a href="#charencoding-section">
 
15
                Character Encoding</a></span></dt></dl></dd><dt><span class="section"><a href="#report-section">Generating Text or HTML Reports</a></span></dt><dt><span class="section"><a href="#pl-section">SqlTool Procedural Language</a></span></dt><dd><dl><dt><span class="section"><a href="#N11915">Variables</a></span></dt><dt><span class="section"><a href="#pl_alias-section">PL Aliases</a></span></dt><dt><span class="section"><a href="#N11993">Logical Expressions</a></span></dt><dt><span class="section"><a href="#N11A0C">Flow Control</a></span></dt></dl></dd><dt><span class="section"><a href="#chunk-section">Chunking</a></span></dt><dd><dl><dt><span class="section"><a href="#N11A6A">Why?</a></span></dt><dt><span class="section"><a href="#N11A71">How?</a></span></dt></dl></dd><dt><span class="section"><a href="#raw-section">Raw Mode</a></span></dt><dt><span class="section"><a href="#N11A9E">PL/SQL</a></span></dt><dt><span class="section"><a href="#N11ABF">Using hsqltool.jar and hsqldbutil.jar</a></span></dt><dt><span class="section"><a href="#N11B18">Character-Separated-Value Imports and Exports</a></span></dt><dd><dl><dt><span class="section"><a href="#N11B36">Simple CSV exports and imports using default settings</a></span></dt><dt><span class="section"><a href="#N11B7B">Specifying queries, delimiters, file names, table names,
 
16
                columns</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#sqlsyntax-chapter">9. SQL Syntax</a></span></dt><dd><dl><dt><span class="section"><a href="#N11BFC">Notational Conventions Used in this Chapter</a></span></dt><dt><span class="section"><a href="#N11C19">SQL Commands</a></span></dt><dd><dl><dt><span class="section"><a href="#alter_index-section">ALTER INDEX</a></span></dt><dt><span class="section"><a href="#alter_sequence-section">ALTER SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11C38">ALTER SCHEMA</a></span></dt><dt><span class="section"><a href="#alter_table-section">ALTER TABLE</a></span></dt><dt><span class="section"><a href="#alter_user-section">ALTER USER</a></span></dt><dt><span class="section"><a href="#call-section">CALL</a></span></dt><dt><span class="section"><a href="#checkpoint-section">CHECKPOINT</a></span></dt><dt><span class="section"><a href="#commit-section">COMMIT</a></span></dt><dt><span class="section"><a href="#connect-section">CONNECT</a></span></dt><dt><span class="section"><a href="#create_alias-section">CREATE ALIAS</a></span></dt><dt><span class="section"><a href="#create_index-section">CREATE INDEX</a></span></dt><dt><span class="section"><a href="#create_role-section">CREATE ROLE</a></span></dt><dt><span class="section"><a href="#N11D63">CREATE SCHEMA</a></span></dt><dt><span class="section"><a href="#create_sequence-section">CREATE SEQUENCE</a></span></dt><dt><span class="section"><a href="#create_table-section">CREATE TABLE</a></span></dt><dt><span class="section"><a href="#create_trigger-section">CREATE TRIGGER</a></span></dt><dt><span class="section"><a href="#create_user-section">CREATE USER</a></span></dt><dt><span class="section"><a href="#create_view-section">CREATE VIEW</a></span></dt><dt><span class="section"><a href="#delete-section">DELETE</a></span></dt><dt><span class="section"><a href="#disconnect-section">DISCONNECT</a></span></dt><dt><span class="section"><a href="#drop_index-section">DROP INDEX</a></span></dt><dt><span class="section"><a href="#N11ED7">DROP ROLE</a></span></dt><dt><span class="section"><a href="#drop_sequence-section">DROP SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11EF1">DROP SCHEMA</a></span></dt><dt><span class="section"><a href="#drop_table-section">DROP TABLE</a></span></dt><dt><span class="section"><a href="#drop_trigger-section">DROP TRIGGER</a></span></dt><dt><span class="section"><a href="#drop_user-section">DROP USER</a></span></dt><dt><span class="section"><a href="#drop_view-section">DROP VIEW</a></span></dt><dt><span class="section"><a href="#explain-section">EXPLAIN PLAN</a></span></dt><dt><span class="section"><a href="#grant-section">GRANT</a></span></dt><dt><span class="section"><a href="#insert-section">INSERT</a></span></dt><dt><span class="section"><a href="#revoke-section">REVOKE</a></span></dt><dt><span class="section"><a href="#rollback-section">ROLLBACK</a></span></dt><dt><span class="section"><a href="#savepoint-section">SAVEPOINT</a></span></dt><dt><span class="section"><a href="#script-section">SCRIPT</a></span></dt><dt><span class="section"><a href="#select-section">SELECT</a></span></dt><dt><span class="section"><a href="#set_autocommit-section">SET AUTOCOMMIT</a></span></dt><dt><span class="section"><a href="#collation-section">SET DATABASE COLLATION</a></span></dt><dt><span class="section"><a href="#N1208B">SET CHECKPOINT DEFRAG</a></span></dt><dt><span class="section"><a href="#set_ignorecase-section">SET IGNORECASE</a></span></dt><dt><span class="section"><a href="#set_initialschema-section">SET INITIAL SCHEMA </a></span></dt><dt><span class="section"><a href="#set_logsize-section">SET LOGSIZE</a></span></dt><dt><span class="section"><a href="#set_password-section">SET PASSWORD</a></span></dt><dt><span class="section"><a href="#set_property-section">SET PROPERTY</a></span></dt><dt><span class="section"><a href="#set_refint-section">SET REFERENTIAL INTEGRITY</a></span></dt><dt><span class="section"><a href="#set_schema-section">SET SCHEMA</a></span></dt><dt><span class="section"><a href="#set_scriptformat-section">SET SCRIPTFORMAT</a></span></dt><dt><span class="section"><a href="#set_table_index-section">SET TABLE INDEX</a></span></dt><dt><span class="section"><a href="#set_table_readonly-section">SET TABLE READONLY</a></span></dt><dt><span class="section"><a href="#set_table_source-section">SET TABLE SOURCE</a></span></dt><dt><span class="section"><a href="#set_write_delay-section">SET WRITE DELAY</a></span></dt><dt><span class="section"><a href="#shutdown-section">SHUTDOWN</a></span></dt><dt><span class="section"><a href="#update-section">UPDATE</a></span></dt></dl></dd><dt><span class="section"><a href="#schemanaming-section">Schema object naming</a></span></dt><dt><span class="section"><a href="#datatypes-section">Data Types</a></span></dt><dt><span class="section"><a href="#N12364">SQL Comments</a></span></dt><dt><span class="section"><a href="#stored-section">Stored Procedures / Functions</a></span></dt><dt><span class="section"><a href="#N12395">Built-in Functions and Stored Procedures</a></span></dt><dt><span class="section"><a href="#expression-section">SQL Expression</a></span></dt></dl></dd><dt><span class="appendix"><a href="#building-appendix">A. Building HSQLDB</a></span></dt><dd><dl><dt><span class="section"><a href="#N1269A">Purpose</a></span></dt><dt><span class="section"><a href="#N126A3">Building with Ant</a></span></dt><dd><dl><dt><span class="section"><a href="#N126AA">Obtaining Ant</a></span></dt><dt><span class="section"><a href="#N126C2">Building Hsqldb with Ant</a></span></dt></dl></dd><dt><span class="section"><a href="#N12771">Building with DOS Batch Files</a></span></dt><dt><span class="section"><a href="#N1278A">Hsqldb CodeSwitcher</a></span></dt><dt><span class="section"><a href="#N127B6">Building documentation</a></span></dt></dl></dd><dt><span class="appendix"><a href="#firstclient-appendix">B. First JDBC Client Example</a></span></dt><dt><span class="appendix"><a href="#N12811">C. Hsqldb Database Files and Recovery</a></span></dt><dd><dl><dt><span class="section"><a href="#N12828"></a></span></dt><dt><span class="section"><a href="#N12858">States</a></span></dt><dd><dl><dt><span class="section"><a href="#N1285B"></a></span></dt><dt><span class="section"><a href="#N1288A"></a></span></dt><dt><span class="section"><a href="#N128B9"></a></span></dt></dl></dd><dt><span class="section"><a href="#N128EB">Procedures</a></span></dt><dd><dl><dt><span class="section"><a href="#N128F0">Clean Shutdown</a></span></dt><dt><span class="section"><a href="#N1294A">Startup</a></span></dt><dt><span class="section"><a href="#N1299C">Repair</a></span></dt></dl></dd></dl></dd><dt><span class="appendix"><a href="#N129E2">D. Running Hsqldb with OpenOffice.org 1.1.x</a></span></dt><dd><dl><dt><span class="section"><a href="#N12A02">Introduction</a></span></dt><dt><span class="section"><a href="#N12A0B">Installing</a></span></dt><dt><span class="section"><a href="#N12A10">Setting up OpenOffice.org</a></span></dt><dd><dl><dt><span class="section"><a href="#N12A22">On Windows</a></span></dt><dt><span class="section"><a href="#N12A35">On Linux</a></span></dt></dl></dd></dl></dd><dt><span class="appendix"><a href="#N12A55">E. Hsqldb Test Utility</a></span></dt><dt><span class="appendix"><a href="#N12ACB">F. Database Manager</a></span></dt><dd><dl><dt><span class="section"><a href="#N12AF4">Brief Introduction</a></span></dt><dt><span class="section"><a href="#N12B1E">Auto tree-update</a></span></dt><dt><span class="section"><a href="#N12B35">Automatic Connection</a></span></dt><dt><span class="section"><a href="#N12B43">RC File</a></span></dt><dt><span class="section"><a href="#N12B68">Using the current DatabaseManagers with an older HSQLDB
 
17
    distribution.</a></span></dt><dt><span class="section"><a href="#N12B9A">DatabaseManagerSwing as an Applet</a></span></dt></dl></dd><dt><span class="appendix"><a href="#N12BF8">G. Transfer Tool</a></span></dt><dd><dl><dt><span class="section"><a href="#N12C15">Brief Introduction</a></span></dt></dl></dd></dl></div><div class="list-of-tables"><p><b>List of Tables</b></p><dl><dt>1. <a href="#N1004D">Alternate formats of this document</a></dt><dt>4.1. <a href="#N108EC">Hsqldb URL Components</a></dt><dt>4.2. <a href="#N109FA">Connection Properties</a></dt><dt>4.3. <a href="#N10A81">Hsqldb Server Properties Files</a></dt><dt>4.4. <a href="#N10ACE">Property File Properties</a></dt><dt>4.5. <a href="#N10B3C">Server Property File Properties</a></dt><dt>4.6. <a href="#N10B6F">WebServer Property File Properties</a></dt><dt>4.7. <a href="#N10BEF">Database-specific Property File Properties</a></dt><dt>4.8. <a href="#N10D6C">SQL command properties</a></dt><dt>9.1. <a href="#N12272">Data Types</a></dt></dl></div><div class="list-of-examples"><p><b>List of Examples</b></p><dl><dt>1.1. <a href="#N1018D">Java code to connect to the local Server above</a></dt><dt>2.1. <a href="#N102E6">Column values which satisfy a 2-column UNIQUE
 
18
        constraint</a></dt><dt>2.2. <a href="#N103AB">Query comparison</a></dt><dt>2.3. <a href="#N104F2">Numbering returned rows of a SELECT in sequential order</a></dt><dt>3.1. <a href="#N107DB">server.properties fragment</a></dt><dt>3.2. <a href="#N107EE">example sqltool.rc stanza</a></dt><dt>7.1. <a href="#N11110">Exporting certificate from the server's keystore</a></dt><dt>7.2. <a href="#N11125">Adding a certificate to the client keystore</a></dt><dt>7.3. <a href="#N11134">Specifying your own trust store to a JDBC client</a></dt><dt>7.4. <a href="#N1116A">Running an Hsqldb server with TLS encryption</a></dt><dt>7.5. <a href="#N111AA">Getting a pem-style private key into a JKS keystore</a></dt><dt>8.1. <a href="#N113AE">Sample RC File</a></dt><dt>8.2. <a href="#alias-example">Defining and using a PL alias (PL variable)</a></dt><dt>8.3. <a href="#N116F8">Inserting binary data into database from a file</a></dt><dt>8.4. <a href="#N116FE">Downloading binary data from database to a file</a></dt><dt>8.5. <a href="#N117D5">Piping input into SqlTool</a></dt><dt>8.6. <a href="#N11801">Valid comment example</a></dt><dt>8.7. <a href="#N11809">Invalid comment example</a></dt><dt>8.8. <a href="#N11985">Simple SQL file using PL</a></dt><dt>8.9. <a href="#N11A4E">SQL File showing use of most PL features</a></dt><dt>8.10. <a href="#N11A63">Single-line chunking example</a></dt><dt>8.11. <a href="#N11A76">Multi-line chunking example</a></dt><dt>8.12. <a href="#N11A95">Raw Mode example</a></dt><dt>8.13. <a href="#N11AB8">PL/SQL Example</a></dt><dt>8.14. <a href="#N11B49">CSV Export Example</a></dt><dt>8.15. <a href="#N11B6C">CSV Import Example</a></dt><dt>8.16. <a href="#N11BB2">CSV Export of an Arbitrary SELECT Statement</a></dt><dt>A.1. <a href="#N12763">Buiding the standard Hsqldb jar file with Ant</a></dt><dt>A.2. <a href="#N12793">Example source code before CodeSwitcher is run</a></dt><dt>A.3. <a href="#N1279B">CodeSwitcher command line invocation</a></dt><dt>A.4. <a href="#N127A7">Source code after CodeSwitcher processing</a></dt><dt>A.5. <a href="#N127C8">Building HTML User Guides</a></dt><dt>A.6. <a href="#N127D9">Building User Guides in all formats</a></dt><dt>B.1. <a href="#N1280A">JDBC Client source code example</a></dt></dl></div><div class="preface" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N10030"></a>Introduction</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1003A">Available formats for this document</a></span></dt></dl></div><p>
18
19
            If you notice any mistakes in this document, please email the
19
20
            author listed at the beginning of the chapter.
20
21
            If you have problems with the procedures themselves, please
49
50
      distribute this document without any alteration under the terms of the
50
51
      HSQLDB license. Additional permission is granted to the HSQLDB
51
52
      Development Group to distribute this document with or without
52
 
      alterations under the terms of the HSQLDB license.</p></div></div><div><p class="pubdate">$Date: 2005/07/02 09:11:39 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1009E">Introduction</a></span></dt><dt><span class="section"><a href="#N100B7">Running Tools</a></span></dt><dt><span class="section"><a href="#N100F3">Running Hsqldb</a></span></dt><dt><span class="section"><a href="#N1013D">Server Modes</a></span></dt><dd><dl><dt><span class="section"><a href="#N10148">Hsqldb Server</a></span></dt><dt><span class="section"><a href="#N10157">Hsqldb Web Server</a></span></dt><dt><span class="section"><a href="#N10168">Hsqldb Servlet</a></span></dt><dt><span class="section"><a href="#N101A8">In-Process (Standalone) Mode</a></span></dt><dt><span class="section"><a href="#N101CA">Memory-Only Databases</a></span></dt></dl></dd><dt><span class="section"><a href="#N101D8">General</a></span></dt><dd><dl><dt><span class="section"><a href="#N101DB">Closing the Database</a></span></dt><dt><span class="section"><a href="#N101E6">Using Multiple Databases in One JVM</a></span></dt><dt><span class="section"><a href="#N101EF">Creating a New Database</a></span></dt></dl></dd><dt><span class="section"><a href="#N10202">Using the Database Engine</a></span></dt><dd><dl><dt><span class="section"><a href="#N1023C">Different Types of Tables</a></span></dt><dt><span class="section"><a href="#N10255">Constraints and Indexes</a></span></dt><dt><span class="section"><a href="#N10268">SQL Support</a></span></dt><dt><span class="section"><a href="#N10281">JDBC Support</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1009E"></a>Introduction</h2></div></div><div></div></div><p>The HSQLDB jar package is located in the /lib directory and contains
 
53
      alterations under the terms of the HSQLDB license.</p></div></div><div><p class="pubdate">$Date: 2005/09/19 00:03:12 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1009E">Introduction</a></span></dt><dt><span class="section"><a href="#N100B7">Running Tools</a></span></dt><dt><span class="section"><a href="#N100F3">Running Hsqldb</a></span></dt><dt><span class="section"><a href="#N1013D">Server Modes</a></span></dt><dd><dl><dt><span class="section"><a href="#N10148">Hsqldb Server</a></span></dt><dt><span class="section"><a href="#N10157">Hsqldb Web Server</a></span></dt><dt><span class="section"><a href="#N10168">Hsqldb Servlet</a></span></dt><dt><span class="section"><a href="#N101A8">In-Process (Standalone) Mode</a></span></dt><dt><span class="section"><a href="#N101CA">Memory-Only Databases</a></span></dt></dl></dd><dt><span class="section"><a href="#N101D8">General</a></span></dt><dd><dl><dt><span class="section"><a href="#N101DB">Closing the Database</a></span></dt><dt><span class="section"><a href="#N101E6">Using Multiple Databases in One JVM</a></span></dt><dt><span class="section"><a href="#N101EF">Creating a New Database</a></span></dt></dl></dd><dt><span class="section"><a href="#N10202">Using the Database Engine</a></span></dt><dd><dl><dt><span class="section"><a href="#N1023C">Different Types of Tables</a></span></dt><dt><span class="section"><a href="#N10255">Constraints and Indexes</a></span></dt><dt><span class="section"><a href="#N10268">SQL Support</a></span></dt><dt><span class="section"><a href="#N10281">JDBC Support</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1009E"></a>Introduction</h2></div></div><div></div></div><p>The HSQLDB jar package is located in the /lib directory and contains
53
54
    several components and programs. Different commands are used to run each
54
55
    program.</p><div class="itemizedlist"><p class="title"><b>Components of the Hsqldb jar package</b></p><ul type="disc"><li><p>HSQLDB RDBMS</p></li><li><p>HSQLDB JDBC Driver</p></li><li><p>Database Manager (Swing and AWT versions)</p></li><li><p>Query Tool (AWT)</p></li><li><p>Sql Tool (command line)</p></li></ul></div><p>The HSQLDB RDBMS and JDBC Driver provide the core functionality. The
55
56
    rest are general-purpose database tools that can be used with any database
122
123
      above is used for running the server. The following example of the
123
124
      command for starting the server starts the server with one (default)
124
125
      database with files named "mydb.*".</p><div class="informalexample"><pre class="screen">
125
 
    java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 mydb -dbname.0 xdb</pre></div><p>The command line argument <tt class="literal">-?</tt> can be used to get
 
126
    java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb</pre></div><p>The command line argument <tt class="literal">-?</tt> can be used to get
126
127
      a list of available arguments.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N10157"></a>Hsqldb Web Server</h3></div></div><div></div></div><p>This mode is used when access to the computer hosting the database
127
128
      server is restricted to the HTTP protocol. The only reason for using the
128
129
      Web Server mode is restrictions imposed by firewalls on the client or
914
915
            <span class="bold"><b>HSQLDB_OWNER</b></span>'s home directory.
915
916
            Use <tt class="literal">chmod</tt> to make the file readable and
916
917
            writable only to <span class="bold"><b>HSQLDB_OWNER</b></span>.
917
 
        </p><pre class="programlisting"># $Id: sqltool.rc,v 1.14 2005/05/22 04:46:16 unsaved Exp $
 
918
        </p><pre class="programlisting"># $Id: sqltool.rc,v 1.17 2005/11/06 18:01:49 unsaved Exp $
918
919
 
919
920
# This is a sample RC configuration file used by SqlTool, DatabaseManager,
920
921
# and any other program that uses the org.hsqldb.util.RCData class.
986
987
#password losung1
987
988
#driver org.postgresql.Driver
988
989
 
989
 
# Template for a MySQL database
 
990
# Template for a MySQL database.  MySQL has poor JDBC support.
990
991
#urlid mysql-testdb
991
 
#url jdbc:mysql:///test
 
992
#url jdbc:mysql://hostname:3306/dbname
992
993
#username root
993
994
#username blaine
994
995
#password hiddenpwd
995
996
#driver com.mysql.jdbc.Driver
 
997
 
 
998
# Note that "databases" in SQL Server and Sybase are traditionally used for
 
999
# the same purpose as "schemas" with more SQL-compliant databases.
 
1000
 
 
1001
# Template for a Microsoft SQL Server database
 
1002
url jdbc:microsoft:sqlserver://hostname;DatabaseName=DbName;SelectMethod=Cursor
 
1003
# The SelectMethod setting is required to do more than one thing on a JDBC
 
1004
# session (I guess Microsoft thought nobody would really use Java for 
 
1005
# anything other than a "hello world" program).
 
1006
# This is for Microsoft's SQL Server 2000 driver (requires mssqlserver.jar
 
1007
# and msutil.jar).
 
1008
driver com.microsoft.jdbc.sqlserver.SQLServerDriver
 
1009
username myuser
 
1010
password hiddenpwd
 
1011
 
 
1012
# Template for a Sybase database
 
1013
urlid sybase
 
1014
url jdbc:sybase:Tds:hostname:4100/dbname
 
1015
username blaine
 
1016
password hiddenpwd
 
1017
# This is for the jConnect driver (requires jconn3.jar).
 
1018
driver com.sybase.jdbc3.jdbc.SybDriver
996
1019
</pre><p>
997
1020
            We will be using the "localhost-sa" sample urlid definition from 
998
1021
            the config file.
2173
2196
    imports a pipe-delimited text file from the database's file directory into
2174
2197
    an existing normal table. You can edit a copy of this file and use it
2175
2198
    directly with <a href="#sqltool-chapter" title="Chapter&nbsp;8.&nbsp;SqlTool">SqlTool</a>, or you can
2176
 
    use the SQL therein as a model (using any SQL client at all).</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="tls-chapter"></a>Chapter&nbsp;7.&nbsp;TLS</h2></div><div><h3 class="subtitle"><i>TLS Support (a.k.a. SSL)</i></h3></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:blaine.simpson@admc.com">blaine.simpson@admc.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/05/31 20:59:13 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N110D1">Requirements</a></span></dt><dt><span class="section"><a href="#N110EE">Encrypting your JDBC connection</a></span></dt><dd><dl><dt><span class="section"><a href="#N110F3">Client-Side</a></span></dt><dt><span class="section"><a href="#N1115E">Server-Side</a></span></dt></dl></dd><dt><span class="section"><a href="#jsse-section">JSSE</a></span></dt><dt><span class="section"><a href="#privatekey-section">Making a Private-key Keystore</a></span></dt><dd><dl><dt><span class="section"><a href="#N1119A">CA-Signed Cert</a></span></dt><dt><span class="section"><a href="#N111C3">Non-CA-Signed Cert</a></span></dt></dl></dd><dt><span class="section"><a href="#N111D0">Automatic Server or WebServer startup on UNIX</a></span></dt></dl></div><p>
 
2199
    use the SQL therein as a model (using any SQL client at all).</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="tls-chapter"></a>Chapter&nbsp;7.&nbsp;TLS</h2></div><div><h3 class="subtitle"><i>TLS Support (a.k.a. SSL)</i></h3></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:blaine.simpson@admc.com">blaine.simpson@admc.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/11/06 20:03:37 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N110D1">Requirements</a></span></dt><dt><span class="section"><a href="#N110EE">Encrypting your JDBC connection</a></span></dt><dd><dl><dt><span class="section"><a href="#N110F3">Client-Side</a></span></dt><dt><span class="section"><a href="#N1115E">Server-Side</a></span></dt></dl></dd><dt><span class="section"><a href="#jsse-section">JSSE</a></span></dt><dt><span class="section"><a href="#privatekey-section">Making a Private-key Keystore</a></span></dt><dd><dl><dt><span class="section"><a href="#N1119A">CA-Signed Cert</a></span></dt><dt><span class="section"><a href="#N111C3">Non-CA-Signed Cert</a></span></dt></dl></dd><dt><span class="section"><a href="#N111D0">Automatic Server or WebServer startup on UNIX</a></span></dt></dl></div><p>
2177
2200
        The instructions in this document are liable to change at any time.
2178
2201
        In particular, we will be changing the method to supply the server-side
2179
2202
        certificate password.
2241
2264
            </p><p>
2242
2265
                    You may already have an X509 cert for your server.
2243
2266
                    If you have a server keystore, then you can generate a
2244
 
                    X590 cert like this.
 
2267
                    X509 cert like this.
2245
2268
                <div class="example"><a name="N11110"></a><p class="title"><b>Example&nbsp;7.1.&nbsp;Exporting certificate from the server's keystore</b></p><pre class="screen">
2246
2269
    keytool -export -keystore server.store -alias existing_alias -file server.cer</pre></div>
2247
2270
                In this example, <tt class="filename">server.cer</tt> is the X509
2257
2280
                keystore, or create a new keystore if 
2258
2281
                <tt class="filename">client.store</tt> doesn't exist.
2259
2282
            </p><div class="example"><a name="N11125"></a><p class="title"><b>Example&nbsp;7.2.&nbsp;Adding a certificate to the client keystore</b></p><pre class="screen">
2260
 
    keytool -import -trustcacerts -keystore trust.store -alias new_alias -file server.cer</pre></div><p>
 
2283
keytool -import -trustcacerts -keystore trust.store -alias new_alias -file server.cer</pre></div><p>
2261
2284
                If you are making a new keystore, you probably want to start
2262
2285
                with a copy of your system default keystore which you can
2263
2286
                find somewhere under your JAVA_HOME directory (typically
2309
2332
                password of the keystore (and to the private key-- they have 
2310
2333
                to be the same).
2311
2334
            </p><div class="example"><a name="N1116A"></a><p class="title"><b>Example&nbsp;7.4.&nbsp;Running an Hsqldb server with TLS encryption</b></p><pre class="screen">
2312
 
    java -Djavax.net.ssl.keyStorePassword=secret -Djavax.net.ssl.keyStore=/usr/hsqldb/db/db3/server.store  \
 
2335
    java -Djavax.net.ssl.keyStorePassword=secret  \
 
2336
        -Djavax.net.ssl.keyStore=/usr/hsqldb/db/db3/server.store  \
2313
2337
        -cp /path/to/hsqldb.jar org.hsqldb.Server</pre></div><p>
2314
2338
                (This is a single command that I have broken into 2 lines using
2315
2339
                my shell's \ line-continuation feature.
2362
2386
                Because I have spent a lot of time on this document already, I 
2363
2387
                am just giving you an example.
2364
2388
            </p><div class="example"><a name="N111AA"></a><p class="title"><b>Example&nbsp;7.5.&nbsp;Getting a pem-style private key into a JKS keystore</b></p><pre class="screen">
2365
 
    openssl pkcs8 -topk8 -outform DER -in Xpvk.pem -inform PEM -out Xpvk.pk8 -nocrypt
2366
 
 
2367
 
    openssl x509 -in Xcert.pem -out Xcert.der -outform DER
2368
 
 
2369
 
    java DERImport new.keystore NEWALIAS Xpvk.pk8 Xcert.der</pre></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>
 
2389
openssl pkcs8 -topk8 -outform DER -in Xpvk.pem -inform PEM -out Xpvk.pk8 -nocrypt
 
2390
 
 
2391
openssl x509 -in Xcert.pem -out Xcert.der -outform DER
 
2392
 
 
2393
java DERImport new.keystore NEWALIAS Xpvk.pk8 Xcert.der</pre></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>
2370
2394
                Make sure to set the password of the key exactly the same as 
2371
2395
                the password for the keystore!
2372
2396
            </p></div><p>
2399
2423
            above</a> still applies.
2400
2424
            The password will be visible to any minimally competent local
2401
2425
            UNIX user who wants to see it.
2402
 
        </p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="sqltool-chapter"></a>Chapter&nbsp;8.&nbsp;SqlTool</h2></div><div><h3 class="subtitle"><i>SqlTool Manual</i></h3></div><div><div class="author"><h3 class="author"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:blaine.simpson@admc.com">blaine.simpson@admc.com</a>&gt;</tt></div></div><div><p class="pubdate">$Date: 2005/06/04 17:43:30 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1120E">Purpose</a></span></dt><dd><dl><dt><span class="section"><a href="#N11217">Recent changes</a></span></dt></dl></dd><dt><span class="section"><a href="#baremin-section">The Bare Minimum</a></span></dt><dd><dl><dt><span class="section"><a href="#N112EC">Non-displayable Types</a></span></dt><dt><span class="section"><a href="#N11311">Desktop shortcuts</a></span></dt><dt><span class="section"><a href="#N1138F">Loading sample data</a></span></dt></dl></dd><dt><span class="section"><a href="#auth-section">RC File Authentication Setup</a></span></dt><dt><span class="section"><a href="#N11428">
 
2426
        </p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="sqltool-chapter"></a>Chapter&nbsp;8.&nbsp;SqlTool</h2></div><div><h3 class="subtitle"><i>SqlTool Manual</i></h3></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:blaine.simpson@admc.com">blaine.simpson@admc.com</a>&gt;</tt></div><div class="author"><h3 class="author"><span class="firstname">Dan</span> <span class="surname">Shinton</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:dan@shinton.net">dan@shinton.net</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2006/03/16 22:47:19 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N11219">Purpose</a></span></dt><dd><dl><dt><span class="section"><a href="#N11222">Recent changes</a></span></dt></dl></dd><dt><span class="section"><a href="#baremin-section">The Bare Minimum</a></span></dt><dd><dl><dt><span class="section"><a href="#N112DD">Non-displayable Types</a></span></dt><dt><span class="section"><a href="#N11302">Desktop shortcuts</a></span></dt><dt><span class="section"><a href="#N11380">Loading sample data</a></span></dt></dl></dd><dt><span class="section"><a href="#auth-section">RC File Authentication Setup</a></span></dt><dt><span class="section"><a href="#ilauth-section">Using Inline RC Authentication</a></span></dt><dt><span class="section"><a href="#N11461">
2403
2427
            Using the current version of SqlTool with an older HSQLDB
2404
2428
            distribution.
2405
 
        </a></span></dt><dt><span class="section"><a href="#int-section">Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#N114AE">Command Types</a></span></dt><dt><span class="section"><a href="#N11502">Special Commands</a></span></dt><dt><span class="section"><a href="#N115B6">Buffer Commands</a></span></dt><dt><span class="section"><a href="#interactive_pl_commands-section">PL Commands</a></span></dt><dt><span class="section"><a href="#binary_files-section">
2406
 
                Storing and retrieving binary files</a></span></dt><dt><span class="section"><a href="#N116DA">SQL History</a></span></dt><dt><span class="section"><a href="#N116E9">Shell scripting and command-line piping</a></span></dt><dt><span class="section"><a href="#N116F2">Emulating Non-Interactive mode</a></span></dt></dl></dd><dt><span class="section"><a href="#nonint-section">Non-Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#sqlswitch-section">Giving SQL on the Command Line</a></span></dt><dt><span class="section"><a href="#N11755">SQL Files</a></span></dt><dt><span class="section"><a href="#scripting-section">Piping and shell scripting</a></span></dt><dt><span class="section"><a href="#N117BD">Optimally Compatible SQL Files</a></span></dt><dt><span class="section"><a href="#N117D0">Comments</a></span></dt><dt><span class="section"><a href="#N117F3">Special Commands and Buffer Commands in SQL Files</a></span></dt><dt><span class="section"><a href="#N1185E">Automation</a></span></dt><dt><span class="section"><a href="#N11869">Getting Interactive Functionality with SQL Files</a></span></dt><dt><span class="section"><a href="#charencoding-section">
2407
 
                Character Encoding</a></span></dt></dl></dd><dt><span class="section"><a href="#report-section">Generating Text or HTML Reports</a></span></dt><dt><span class="section"><a href="#pl-section">SqlTool Procedural Language</a></span></dt><dd><dl><dt><span class="section"><a href="#N118F8">Variables</a></span></dt><dt><span class="section"><a href="#pl_alias-section">PL Aliases</a></span></dt><dt><span class="section"><a href="#N11976">Logical Expressions</a></span></dt><dt><span class="section"><a href="#N119EF">Flow Control</a></span></dt></dl></dd><dt><span class="section"><a href="#chunk-section">Chunking</a></span></dt><dd><dl><dt><span class="section"><a href="#N11A4D">Why?</a></span></dt><dt><span class="section"><a href="#N11A54">How?</a></span></dt></dl></dd><dt><span class="section"><a href="#raw-section">Raw Mode</a></span></dt><dt><span class="section"><a href="#N11A81">PL/SQL</a></span></dt><dt><span class="section"><a href="#N11AA2">Using hsqltool.jar and hsqldbutil.jar</a></span></dt><dt><span class="section"><a href="#N11AFB">Unit Testing SqlTool</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1120E"></a>Purpose</h2></div></div><div></div></div><p>
 
2429
        </a></span></dt><dt><span class="section"><a href="#int-section">Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#N114E7">Command Types</a></span></dt><dt><span class="section"><a href="#N11538">Special Commands</a></span></dt><dt><span class="section"><a href="#N115E6">Buffer Commands</a></span></dt><dt><span class="section"><a href="#interactive_pl_commands-section">PL Commands</a></span></dt><dt><span class="section"><a href="#binary_files-section">
 
2430
                Storing and retrieving binary files</a></span></dt><dt><span class="section"><a href="#N1170A">SQL History</a></span></dt><dt><span class="section"><a href="#N11719">Shell scripting and command-line piping</a></span></dt><dt><span class="section"><a href="#N11722">Emulating Non-Interactive mode</a></span></dt></dl></dd><dt><span class="section"><a href="#nonint-section">Non-Interactive</a></span></dt><dd><dl><dt><span class="section"><a href="#sqlswitch-section">Giving SQL on the Command Line</a></span></dt><dt><span class="section"><a href="#N1177D">SQL Files</a></span></dt><dt><span class="section"><a href="#scripting-section">Piping and shell scripting</a></span></dt><dt><span class="section"><a href="#N117E5">Optimally Compatible SQL Files</a></span></dt><dt><span class="section"><a href="#N117F8">Comments</a></span></dt><dt><span class="section"><a href="#N1181B">Special Commands and Buffer Commands in SQL Files</a></span></dt><dt><span class="section"><a href="#N11880">Automation</a></span></dt><dt><span class="section"><a href="#N1188B">Getting Interactive Functionality with SQL Files</a></span></dt><dt><span class="section"><a href="#charencoding-section">
 
2431
                Character Encoding</a></span></dt></dl></dd><dt><span class="section"><a href="#report-section">Generating Text or HTML Reports</a></span></dt><dt><span class="section"><a href="#pl-section">SqlTool Procedural Language</a></span></dt><dd><dl><dt><span class="section"><a href="#N11915">Variables</a></span></dt><dt><span class="section"><a href="#pl_alias-section">PL Aliases</a></span></dt><dt><span class="section"><a href="#N11993">Logical Expressions</a></span></dt><dt><span class="section"><a href="#N11A0C">Flow Control</a></span></dt></dl></dd><dt><span class="section"><a href="#chunk-section">Chunking</a></span></dt><dd><dl><dt><span class="section"><a href="#N11A6A">Why?</a></span></dt><dt><span class="section"><a href="#N11A71">How?</a></span></dt></dl></dd><dt><span class="section"><a href="#raw-section">Raw Mode</a></span></dt><dt><span class="section"><a href="#N11A9E">PL/SQL</a></span></dt><dt><span class="section"><a href="#N11ABF">Using hsqltool.jar and hsqldbutil.jar</a></span></dt><dt><span class="section"><a href="#N11B18">Character-Separated-Value Imports and Exports</a></span></dt><dd><dl><dt><span class="section"><a href="#N11B36">Simple CSV exports and imports using default settings</a></span></dt><dt><span class="section"><a href="#N11B7B">Specifying queries, delimiters, file names, table names,
 
2432
                columns</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11219"></a>Purpose</h2></div></div><div></div></div><p>
2408
2433
            This document explains how to use SqlTool, the main purpose of
2409
2434
            which is to read your SQL text file or stdin, and execute the SQL 
2410
2435
            commands therein against a JDBC database.
2414
2439
            control and error handling).
2415
2440
        </p><p>
2416
2441
            Some of the examples below use quoting which works exactly
2417
 
            as-is for any normal UNIX shell.
 
2442
            as-is for any Bourne-compatible UNIX shell.
 
2443
            (Only line-continuation would need to be changed for C-compatible
 
2444
            UNIX shells).
2418
2445
            I have not yet tested these commands on Windows, and I doubt
2419
2446
            whether the quoting will work just like this (though it is
2420
2447
            possible).
2421
2448
            SqlTool is still a very useful tool even if you have no quoting
2422
2449
            capability at all.
2423
2450
        </p><p>
2424
 
            This document is now updated for version 1.46 of SqlTool and
2425
 
            1.114 of SqlFile (the latter is the class which does most of the
 
2451
            If you are using SqlTool from a HSQDLB distribution before
 
2452
            version 1.8.0.0 final, you should use the documentation with that
 
2453
            distribution
 
2454
            (because, for brevity, I do not here indicate changes made to
 
2455
            behavior before 1.8.0.0 final).
 
2456
            This document is now updated for the current versions of SqlTool
 
2457
            and SqlFile at the time I am writing this (versions 1.50 and
 
2458
            1.130 correspondingly, SqlFile is the class which does most of the
2426
2459
            work for SqlTool).
 
2460
            Therefore, if you are using a version of SqlTool or SqlFile that
 
2461
            is more than a couple revisions greater, you should find a newer
 
2462
            version of this document.
 
2463
            (The imprecision is due to content-independent revision increments
 
2464
            at build time, and the likelihood of one or two 
 
2465
            behavior-independent bug fixes after public releases).
2427
2466
            The startup banner will report both versions when you run SqlTool
2428
2467
            interactively.
2429
 
            I expect this version of this document to accurately describe 
2430
 
            SqlTool for some unknown number of versions into the future.
2431
 
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11217"></a>Recent changes</h3></div></div><div></div></div><p>This section lists changes to SqlTool since the last
 
2468
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11222"></a>Recent changes</h3></div></div><div></div></div><p>This section lists changes to SqlTool since the last
2432
2469
                major release of HSQLDB.
2433
 
                For this version of this document, that means, changes since
2434
 
                HSQLDB versions 1.7.x.
 
2470
                For this revision of this document, this list consists of
 
2471
                significant changes made to SqlTool AFTER the final 1.8.0.0
 
2472
                HSQLDB release.
2435
2473
            </p><div class="itemizedlist"><ul type="disc"><li>
2436
 
                    Slight adjustments to command-line switch behavior to make
2437
 
                    them more convenient for the most common forms of usage.
2438
 
                </li><li>
2439
 
                    Changed PL alias prefix from * to / (in order to allow for
2440
 
                    the following improvement).
2441
 
                </li><li>
2442
 
                    Removed the funny whitespace requirements for PL commands.
2443
 
                </li><li>
2444
 
                    Uppercase/lowercase requirements for special commands are
2445
 
                    relegated to the database.
2446
 
                    Therefore, in special commands only, you are safest to key 
2447
 
                    in object names in the case exactly as the real object name
2448
 
                    in your database.
2449
 
                    This is the only way for me to remove ambiguity from 
2450
 
                    case-specific object names without having to code different
2451
 
                    rules for every database.
2452
 
                    (Because, for example, Postgresql defaults object names to
2453
 
                    lowercase and Oracle defaults them to uppercase).
2454
 
                </li><li>
2455
 
                    Added special command \dn.
2456
 
                </li><li>
2457
 
                    Added special command \ds (old \ds command is now \dS).
2458
 
                </li><li>
2459
 
                    Added special command \di.
2460
 
                </li><li>
2461
 
                    Renamed special command \* to \c.  (\* still supported
2462
 
                    for backward compatibility).
2463
 
                </li><li>
2464
 
                    Not so stingy about saving commands in history.
2465
 
                </li><li>
2466
 
                    Allow optional filter substring for many more \d commands,
2467
 
                    including for "\d TABLENAME".
2468
 
                </li><li>
2469
 
                    Implemented special use of substrings ending with dot.
2470
 
                    These do not just filter on the string, but mean to
2471
 
                    filter to only objects with this exact schema.
2472
 
                </li><li>
2473
 
                    \da and \ds commands now work for HSQLDB servers, even 
2474
 
                    though HSQLDB Aliases and Sequences are not listed in the
2475
 
                    JDBC Metadata.
2476
 
                </li><li>
2477
 
                    Improved exception handling.
2478
 
                </li><li>
2479
 
                    Implemented Raw SQL mode, and ability for users to enter
2480
 
                    PL/SQL.
2481
 
                </li><li>
2482
 
                    Fixed open Statement bug (HSQLDB bug #1191524).
2483
 
                </li><li>
2484
 
                    Improved Oracle idiosyncracy work-arounds.
2485
 
                </li><li>
2486
 
                    Added support for all non-text type fields, including BLOBs.
2487
 
                </li><li>
2488
 
                    Can download and upload both ASCII and binary column
2489
 
                    values to/from local files.
2490
 
                </li><li>
2491
 
                    Better display of null values occurring in result sets.
2492
 
                </li><li>
2493
 
                    RC file functionality isolated into separate class, RCData.
2494
 
                    Other programs can now use RC files by using this class.
2495
 
                </li></ul></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="baremin-section"></a>The Bare Minimum You Need to Know to Run SqlTool</h2></div></div><div></div></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
 
2474
                    Fixed bug where PL "end" command was still requiring old 
 
2475
                    syntax (wrt white space).
 
2476
                    Fixed for HSQLDB v. 1.8.0.2.
 
2477
                </li><li>
 
2478
                    Fixed NPE sometimes encountered when fetching null 
 
2479
                    Timestamp values.
 
2480
                    Fixed for HSQLDB v. 1.8.0.2.
 
2481
                </li><li>
 
2482
                    Implemented new \dr command for HSQLDB and Sybase servers.
 
2483
                    Implemented \du for Sybase.
 
2484
                    Added for HSQLDB v. 1.8.0.3.
 
2485
                </li><li>
 
2486
                    Implemented CSV eXport and iMport commands \x and \m.
 
2487
                    Added for HSQLDB v. 1.8.0.3.
 
2488
                </li><li>
 
2489
                    Implemented method for specifying RC file parameters as a
 
2490
                    command-line switch. Modified SqlTool to now accepts case
 
2491
                    insensitive command-line switches. Added for HSQLDB v. 1.8.1.
 
2492
                </li></ul></div><p>
 
2493
                When recently changed or added features (i.e, those items
 
2494
                in the preceding list) are described in the main document 
 
2495
                below, there is a <span class="emphasis"><em>Note</em></span> at that point
 
2496
                indicating when the feature was added or changed.
 
2497
            </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="baremin-section"></a>The Bare Minimum You Need to Know to Run SqlTool</h2></div></div><div></div></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
2496
2498
            If you are using an Oracle database server, it will commit your
2497
2499
            current transaction if you cleanly disconnect, regardless of
2498
2500
            whether you have set auto-commit or not.
2525
2527
                    Edit the file if you need to change the target Server URL, 
2526
2528
                    username, password, character set, JDBC driver, or TLS 
2527
2529
                    trust store as documented in the 
2528
 
                    <a href="#auth-section" title="RC File Authentication Setup">RC File Authentication Setup</a> section.
 
2530
                    <a href="#auth-section" title="RC File Authentication Setup">RC File Authentication Setup</a>
 
2531
                    section.</p><p><span class="bold"><b>OR</b></span></p><p>Use the <tt class="literal">--inlineRc</tt> command-line
 
2532
                    switch to specify your connection parameters as documented
 
2533
                    in the <a href="#ilauth-section" title="Using Inline RC Authentication">Using Inline RC Authentication</a>
 
2534
                    section.
2529
2535
                </p></li><li><p>
2530
2536
                    Find out where your hsqldb.jar file resides.
2531
2537
                    It typically resides at
2607
2613
            (With some terms you click &amp; drag the frame edges to resize,
2608
2614
            with others you use a menu system where you can enter the number
2609
2615
            of columns).
2610
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N112EC"></a>Non-displayable Types</h3></div></div><div></div></div><p>
 
2616
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N112DD"></a>Non-displayable Types</h3></div></div><div></div></div><p>
2611
2617
            There are many SQL types which SqlTool (being a text-based
2612
2618
            program) can't display properly.
2613
2619
            This includes the SQL types <tt class="literal">BLOB</tt>,
2639
2645
                Storing and retrieving binary files">
2640
2646
                Storing and retrieving binary files</a>
2641
2647
            section.
2642
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11311"></a>Desktop shortcuts</h3></div></div><div></div></div><p>
 
2648
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11302"></a>Desktop shortcuts</h3></div></div><div></div></div><p>
2643
2649
                Desktop shortcuts and quick launch icons are useful, especially 
2644
2650
                if you often run SqlTool with the same set of arguments.
2645
2651
                It's really easy to set up several of them-- one for each 
2699
2705
                    to) a desktop shortcut icon, click and drag it to your 
2700
2706
                    quick launch bar.  (You may or may not need to edit the
2701
2707
                    Windows Toolbar properties to let you add new items).
2702
 
                </p></li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1138F"></a>Loading sample data</h3></div></div><div></div></div><p>
 
2708
                </p></li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11380"></a>Loading sample data</h3></div></div><div></div></div><p>
2703
2709
                If you want some sample database objects and data to play 
2704
2710
                with, execute the <tt class="filename">sampledata.sql</tt> SQL 
2705
2711
                file.
2716
2722
                For other (persistent) databases, the data will reside in 
2717
2723
                your database until you drop the tables.
2718
2724
            </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="auth-section"></a>RC File Authentication Setup</h2></div></div><div></div></div><p>
2719
 
            Authentication setup is accomplished by creating a text RC
2720
 
            configuration file.
 
2725
            RC file authentication setup is accomplished by creating a text
 
2726
            RC configuration file.
2721
2727
            In this section, when I say <span class="emphasis"><em>configuration</em></span>
2722
2728
            or <span class="emphasis"><em>config</em></span> file, I mean an RC configuration 
2723
2729
            file.
2729
2735
            The following sample RC file resides at 
2730
2736
            <tt class="filename">src/org/hsqldb/sample/sqltool.rc</tt> in your
2731
2737
            HSQLDB distribution.
2732
 
        </p><div class="example"><a name="N113BD"></a><p class="title"><b>Example&nbsp;8.1.&nbsp;Sample RC File</b></p><pre class="programlisting"># $Id: sqltool.rc,v 1.14 2005/05/22 04:46:16 unsaved Exp $
 
2738
        </p><div class="example"><a name="N113AE"></a><p class="title"><b>Example&nbsp;8.1.&nbsp;Sample RC File</b></p><pre class="programlisting"># $Id: sqltool.rc,v 1.17 2005/11/06 18:01:49 unsaved Exp $
2733
2739
 
2734
2740
# This is a sample RC configuration file used by SqlTool, DatabaseManager,
2735
2741
# and any other program that uses the org.hsqldb.util.RCData class.
2801
2807
#password losung1
2802
2808
#driver org.postgresql.Driver
2803
2809
 
2804
 
# Template for a MySQL database
 
2810
# Template for a MySQL database.  MySQL has poor JDBC support.
2805
2811
#urlid mysql-testdb
2806
 
#url jdbc:mysql:///test
 
2812
#url jdbc:mysql://hostname:3306/dbname
2807
2813
#username root
2808
2814
#username blaine
2809
2815
#password hiddenpwd
2810
2816
#driver com.mysql.jdbc.Driver
 
2817
 
 
2818
# Note that "databases" in SQL Server and Sybase are traditionally used for
 
2819
# the same purpose as "schemas" with more SQL-compliant databases.
 
2820
 
 
2821
# Template for a Microsoft SQL Server database
 
2822
url jdbc:microsoft:sqlserver://hostname;DatabaseName=DbName;SelectMethod=Cursor
 
2823
# The SelectMethod setting is required to do more than one thing on a JDBC
 
2824
# session (I guess Microsoft thought nobody would really use Java for 
 
2825
# anything other than a "hello world" program).
 
2826
# This is for Microsoft's SQL Server 2000 driver (requires mssqlserver.jar
 
2827
# and msutil.jar).
 
2828
driver com.microsoft.jdbc.sqlserver.SQLServerDriver
 
2829
username myuser
 
2830
password hiddenpwd
 
2831
 
 
2832
# Template for a Sybase database
 
2833
urlid sybase
 
2834
url jdbc:sybase:Tds:hostname:4100/dbname
 
2835
username blaine
 
2836
password hiddenpwd
 
2837
# This is for the jConnect driver (requires jconn3.jar).
 
2838
driver com.sybase.jdbc3.jdbc.SybDriver
2811
2839
</pre></div><p>
2812
2840
            You can put this file anywhere you want to, and specify the 
2813
2841
            location to SqlTool/DatabaseManager/DatabaseManagerSwing by
2880
2908
            </dd></dl></div><p>
2881
2909
            Property and SqlTool command-line switches override settings made 
2882
2910
            in the configuration file.
2883
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11428"></a>
 
2911
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ilauth-section"></a>Using Inline RC Authentication</h2></div></div><div></div></div><p>
 
2912
            Inline RC authentication setup is accomplished by using the
 
2913
            <tt class="literal">--inlineRc</tt> command-line switch on SqlTool.
 
2914
            The <tt class="literal">--inlineRc</tt> command-line switch takes 
 
2915
            two required (URL and USER) and three optional arguments
 
2916
            seperated by commas.
 
2917
        </p><div class="variablelist"><dl><dt><span class="term"><tt class="literal">URL</tt></span></dt><dd>
 
2918
                The JDBC URL of the database you wish to connect to.
 
2919
            </dd><dt><span class="term"><tt class="literal">USER</tt></span></dt><dd>
 
2920
                The username to connect to the database as.
 
2921
            </dd><dt><span class="term"><tt class="literal">DRIVER</tt></span></dt><dd>
 
2922
                The JDBC driver class name. Defaults to
 
2923
                <span class="emphasis"><em>org.hsqldb.jdbcDriver</em></span>.
 
2924
            </dd><dt><span class="term"><tt class="literal">CHARSET</tt></span></dt><dd>
 
2925
                Sets the character encoding. Defaults to <tt class="literal">US-ASCII</tt>.
 
2926
            </dd><dt><span class="term"><tt class="literal">TRUST</tt></span></dt><dd>
 
2927
                The TLS trust keystore file path as documented in the TLS chapter.
 
2928
            </dd></dl></div><p>
 
2929
            Here is an example of invoking SqlTool to connect to a standalone database.
 
2930
            <div class="informalexample"><pre class="screen">
 
2931
    java -jar $HSQLDB_HOME/lib/hsqldb.jar
 
2932
         --inlineRc URL=jdbc:hsqldb:file:/home/dan/dandb,USER=dan</pre></div>
 
2933
        </p><p>
 
2934
            For security reasons, you cannot specify the password as an argument. You
 
2935
            will be prompted for a password as part of the login process.
 
2936
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11461"></a>
2884
2937
            Using the current version of SqlTool with an older HSQLDB
2885
2938
            distribution.
2886
2939
        </h2></div></div><div></div></div><p>This procedure will allow users of a legacy version of
2921
2974
            with their older HSQLDB database, as well as with Postgresql
2922
2975
            and a local application.
2923
2976
            <div class="informalexample"><pre class="screen">
2924
 
CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/myapp/classes:/usr/local/lib/pg.jdbc3.jar
 
2977
CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/classes:/usr/local/lib/pg.jdbc3.jar
2925
2978
export CLASSPATH
2926
2979
java org.hsqldb.util.SqlTool urlid</pre></div>
2927
2980
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="int-section"></a>Interactive</h2></div></div><div></div></div><p>
2993
3046
            <span class="emphasis"><em>appending</em></span> to that 
2994
3047
            <span class="emphasis"><em>now current</em></span> command.
2995
3048
            The buffer is the zeroeth item of the SQL command history.
2996
 
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N114AE"></a>Command Types</h3></div></div><div></div></div><div class="variablelist"><p class="title"><b>Command types</b></p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
 
3049
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N114E7"></a>Command Types</h3></div></div><div></div></div><div class="variablelist"><p class="title"><b>Command types</b></p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
2997
3050
                Above, we said that if you enter an SQL command, one
2998
3051
                SQL command corresponds to one SqlTool command.
2999
3052
                This is the most typical usage, however,
3063
3116
                More detailed explanation of PL variables and the other 
3064
3117
                PL features, with examples, are covered in the
3065
3118
                <a href="#pl-section" title="SqlTool Procedural Language">SqlTool Procedural Language</a> section.
3066
 
                <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
3067
 
                    The requirement for a space after the asterisk has been
3068
 
                    removed with this version of SqlFile.
3069
 
                    It is up to you whether to put a space after the *.
3070
 
                </div>
3071
3119
            </p></dd><dt><span class="term">Raw Mode</span></dt><dd>
3072
3120
                The descriptions of command-types above do not apply to
3073
3121
                <a href="#raw-section" title="Raw Mode">Raw Mode</a>.
3081
3129
                See the 
3082
3130
                <a href="#raw-section" title="Raw Mode">Raw Mode</a> section
3083
3131
                for the details.
3084
 
            </dd></dl></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11502"></a>Special Commands</h3></div></div><div></div></div><div class="variablelist"><p class="title"><b>Essential Special Commands</b></p><dl><dt><span class="term">\?</span></dt><dd>
 
3132
            </dd></dl></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11538"></a>Special Commands</h3></div></div><div></div></div><div class="variablelist"><p class="title"><b>Essential Special Commands</b></p><dl><dt><span class="term">\?</span></dt><dd>
3085
3133
                help
3086
3134
            </dd><dt><span class="term">\q</span></dt><dd>
3087
3135
                quit
3108
3156
                    SqlTool.
3109
3157
                    You can use spaces and other special characters in
3110
3158
                    the string.
3111
 
                </p>
3112
 
                    Note that this is a change in behavior from SqlFile
3113
 
                    before about version 1.100, where substring tests
3114
 
                    were case-insensitive.
3115
 
                <p>
3116
3159
                </p></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>
3117
 
                    Beginning with the current version of SqlFile, filter
3118
 
                    substrings ending with "." are special.
 
3160
                    Filter substrings ending with "." are special.
3119
3161
                    If a substring ends with ".", then this means to narrow
3120
3162
                    the search by the exact, case-sensitive schema name
3121
3163
                    given.
3132
3174
                    double-quote the name, but that is server-side 
3133
3175
                    functionality which cannot (portably) be reproduced by 
3134
3176
                    SqlTool.
3135
 
                </p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
3136
 
                Several new \dX commands have been added with the current
3137
 
                of SqlFile.
3138
 
                Be aware that the meaning of the \s command has changed!
3139
3177
                </p></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>
3140
 
                Indexes may not be searched for by 
3141
 
                <span class="emphasis"><em>substring</em></span>, only by
3142
 
                exact target table name.
3143
 
                So if <tt class="literal">I1</tt> is an index on table
3144
 
                <tt class="literal">T1</tt>, then you list this index by running
3145
 
                "\di T1".
3146
 
                In addition, many database vendors will report on indexes 
3147
 
                only if a target table is identified.
3148
 
                Therefore, "\di" with no argument will fail if your database
3149
 
                vendor does not support it.
3150
 
            </p></div></dd><dt><span class="term">\d objectname [filter]</span></dt><dd><p>
 
3178
                    Indexes may not be searched for by 
 
3179
                    <span class="emphasis"><em>substring</em></span>, only by
 
3180
                    exact target table name.
 
3181
                    So if <tt class="literal">I1</tt> is an index on table
 
3182
                    <tt class="literal">T1</tt>, then you list this index by running
 
3183
                    "\di T1".
 
3184
                    In addition, many database vendors will report on indexes 
 
3185
                    only if a target table is identified.
 
3186
                    Therefore, "\di" with no argument will fail if your database
 
3187
                    vendor does not support it.
 
3188
                </p></div></dd><dt><span class="term">\d objectname [filter]</span></dt><dd><p>
3151
3189
                Lists names of columns in the specified table or view.
3152
3190
                <tt class="literal">objectname</tt> may be a base table name or
3153
3191
                a schema.object name.
3215
3253
            Just restore the command to the buffer (which is the 0th
3216
3254
            element of the history) with a command like "\-4" before you give
3217
3255
            the \w command.
3218
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N115B6"></a>Buffer Commands</h3></div></div><div></div></div><div class="variablelist"><p class="title"><b>Buffer Commands</b></p><dl><dt><span class="term">:?</span></dt><dd>
 
3256
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N115E6"></a>Buffer Commands</h3></div></div><div></div></div><div class="variablelist"><p class="title"><b>Buffer Commands</b></p><dl><dt><span class="term">:?</span></dt><dd>
3219
3257
                help
3220
3258
            </dd><dt><span class="term">:;</span></dt><dd>
3221
3259
                Executes the SQL statement in the current buffer against the 
3401
3439
            into the binary buffer by using the special command \b.
3402
3440
            The very first column value from the first result row of the
3403
3441
            next SQL command will be stored to the binary byte buffer.
3404
 
        </p><div class="example"><a name="N116C8"></a><p class="title"><b>Example&nbsp;8.3.&nbsp;Inserting binary data into database from a file</b></p><pre class="screen">
 
3442
        </p><div class="example"><a name="N116F8"></a><p class="title"><b>Example&nbsp;8.3.&nbsp;Inserting binary data into database from a file</b></p><pre class="screen">
3405
3443
    \bl /tmp/favoritesong.mp3
3406
3444
    \bp
3407
 
    INSERT INTO musictbl (id, stream) VALUES(3112, ?);</pre></div><div class="example"><a name="N116CE"></a><p class="title"><b>Example&nbsp;8.4.&nbsp;Downloading binary data from database to a file</b></p><pre class="screen">
 
3445
    INSERT INTO musictbl (id, stream) VALUES(3112, ?);</pre></div><div class="example"><a name="N116FE"></a><p class="title"><b>Example&nbsp;8.4.&nbsp;Downloading binary data from database to a file</b></p><pre class="screen">
3408
3446
    SELECT stream FROM musictbl WHERE id = 3112;
3409
3447
    \bd /tmp/favoritesong.mp3</pre></div><p>
3410
3448
            You can also store and retrieve text column values to/from
3411
3449
            ASCII files, as documented in the
3412
3450
            <a href="#interactive_pl_commands-section" title="PL Commands">Essential PL Command</a>
3413
3451
            section.
3414
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N116DA"></a>SQL History</h3></div></div><div></div></div><p>
 
3452
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1170A"></a>SQL History</h3></div></div><div></div></div><p>
3415
3453
            The SQL history shown by the \s command, and used by other commands,
3416
3454
            is truncated to 20 entries, since the utility comes from being 
3417
3455
            able to quickly view the history list.
3428
3466
            recall and edit them if you want to.
3429
3467
            The same applies to the editing buffer (which is element 0
3430
3468
            of the history).
3431
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N116E9"></a>Shell scripting and command-line piping</h3></div></div><div></div></div><p>
 
3469
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11719"></a>Shell scripting and command-line piping</h3></div></div><div></div></div><p>
3432
3470
            You normally use non-interactive mode for piping.  You specify
3433
3471
            "-" as the SQL file name.  
3434
3472
            See the <a href="#scripting-section" title="Piping and shell scripting">Piping and shell scripting</a>
3435
3473
            subsection of the Non-Interactive chapter.
3436
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N116F2"></a>Emulating Non-Interactive mode</h3></div></div><div></div></div><p>
 
3474
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11722"></a>Emulating Non-Interactive mode</h3></div></div><div></div></div><p>
3437
3475
            You can run SqlTool <span class="emphasis"><em>interactively</em></span>, but
3438
3476
            have SqlTool behave exactly as if it were processing an SQL
3439
3477
            file (i.e., no command-line prompts, error-handling
3467
3505
            <div class="informalexample"><pre class="screen">
3468
3506
    java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql 'SQL statement' urlid</pre></div>
3469
3507
            <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
3470
 
                With the current version of SqlTool, we have changed the default
3471
 
                behavior of the <tt class="literal">--sql</tt> switch.
3472
3508
                The <tt class="literal">--sql</tt> automatically implies
3473
3509
                <tt class="literal">--noinput</tt>, so if you want to execute the
3474
3510
                specified SQL before <span class="emphasis"><em>and in addition to</em></span> an
3475
3511
                interactive session (or stdin piping), then you must also give
3476
 
                the (new) <span class="emphasis"><em>--stdinput</em></span> switch.
3477
 
                This was changed because it turns out that this is the desired
3478
 
                behavior well over 90% of the time that you would want to use
3479
 
                the <tt class="literal">--sql</tt> switch.
 
3512
                the <span class="emphasis"><em>--stdinput</em></span> switch.
3480
3513
            </p></div> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
3481
 
                Beginning with the current version of SqlTool, SqlTool will
3482
 
                automatically add a trailing semicolon to your
 
3514
                SqlTool will automatically add a trailing semicolon to your
3483
3515
                <tt class="literal">--sql</tt> SQL.  You may still give the trailing
3484
3516
                semicolon if you wish to, and you must still delimit multiple
3485
3517
                SQL commands with a simicolon, of course.
3486
 
                This was changed because in the very few sitations where you
3487
 
                do not want to execute your SQL by a terminating semicolon, you
3488
 
                would be better off using an SQL file.
3489
3518
            </p></div>
3490
3519
            </p><p>
3491
3520
                Since SqlTool transmits SQL statements to the database engine
3511
3540
                this.
3512
3541
            <div class="informalexample"><pre class="programlisting">
3513
3542
    # A shell script
3514
 
    USERCOUNT=`java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql 'select count(*) from usertbl' urlid` || {
 
3543
    USERCOUNT=`java -jar $HSQLDB_HOME/lib/hsqldb.jar --sql '
 
3544
        select count(*) from usertbl
 
3545
    ' urlid` || {
3515
3546
        # Handle the SqlTool error
3516
3547
    }
3517
3548
    echo "There are $USERCOUNT users registered in the database."
3518
3549
    [ "$USECOUNT" -gt 3 ] &amp;&amp; {   # If there are more than 3 users registered
3519
3550
        # Some conditional shell scripting</pre></div>
3520
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11755"></a>SQL Files</h3></div></div><div></div></div><p>
 
3551
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1177D"></a>SQL Files</h3></div></div><div></div></div><p>
3521
3552
                Just give paths to sql text file(s) on the command line after 
3522
3553
                the <span class="emphasis"><em>urlid</em></span>.
3523
3554
            </p><p>
3612
3643
                You can execute this SQL file with a Memory Only database with 
3613
3644
                a command like
3614
3645
            <div class="informalexample"><pre class="programlisting">
3615
 
    java -jar $HSQLDB_HOME/lib/hsqldb.jar  --sql "create user 'tomcat' password 'x'" mem path/to/hsqldb/src/org/hsqldb/sample/sample.sql</pre></div>
 
3646
    java -jar $HSQLDB_HOME/lib/hsqldb.jar  --sql '
 
3647
        create user tomcat password "x"
 
3648
    ' mem path/to/hsqldb/src/org/hsqldb/sample/sample.sql</pre></div>
3616
3649
            </p><p>
3617
3650
                (The <tt class="literal">--sql "create..."</tt> arguments create an
3618
3651
                account which the script uses).
3632
3665
        java -jar $HSQLDB_HOME/lib/hsqldb.jar urlid -</pre></div></p><p>
3633
3666
                This is how you have SqlTool read its input from another 
3634
3667
                program:
3635
 
            <div class="example"><a name="N117AD"></a><p class="title"><b>Example&nbsp;8.5.&nbsp;Piping input into SqlTool</b></p><pre class="screen">
 
3668
            <div class="example"><a name="N117D5"></a><p class="title"><b>Example&nbsp;8.5.&nbsp;Piping input into SqlTool</b></p><pre class="screen">
3636
3669
        echo "Some SQL commands with '$VARIABLES';" |
3637
3670
        java -jar $HSQLDB_HOME/lib/hsqldb.jar urlid -</pre></div></p><p>
3638
3671
                Make sure that you also read the
3640
3673
                section.
3641
3674
                The <tt class="literal">--sql</tt> switch is a great facility to use
3642
3675
                with shell scripts.
3643
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N117BD"></a>Optimally Compatible SQL Files</h3></div></div><div></div></div><p>
 
3676
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N117E5"></a>Optimally Compatible SQL Files</h3></div></div><div></div></div><p>
3644
3677
                If you want your SQL scripts optimally compatible among other
3645
3678
                SQL tools, then don't use any Special or PL Commands.
3646
3679
                SqlTool has default behavior which I think is far superior to 
3667
3700
                any "* " PL commands.
3668
3701
                (And you could not have "* " commands in a compatible SQL 
3669
3702
                file).
3670
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N117D0"></a>Comments</h3></div></div><div></div></div><p>
 
3703
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N117F8"></a>Comments</h3></div></div><div></div></div><p>
3671
3704
                SQL comments of the form <tt class="literal">/*...*/</tt> must begin
3672
3705
                where a (SQL/Special/Buffer/PL) Command could begin, and they
3673
3706
                end with the very first "*/" (regardless of quotes, nesting,
3674
3707
                etc.
3675
3708
                You may have as many blank lines as you want inside of a
3676
3709
                comment.
3677
 
            </p><div class="example"><a name="N117D9"></a><p class="title"><b>Example&nbsp;8.6.&nbsp;Valid comment example</b></p><pre class="programlisting">
 
3710
            </p><div class="example"><a name="N11801"></a><p class="title"><b>Example&nbsp;8.6.&nbsp;Valid comment example</b></p><pre class="programlisting">
3678
3711
    SELECT count(*) FROM atable;
3679
3712
    /* Lots of
3680
3713
     comments interspersed among
3682
3715
    FROM btable;</pre></div><p>
3683
3716
                Notice that a command can start immediate after the comment
3684
3717
                ends.
3685
 
            </p><div class="example"><a name="N117E1"></a><p class="title"><b>Example&nbsp;8.7.&nbsp;Invalid comment example</b></p><pre class="programlisting">
 
3718
            </p><div class="example"><a name="N11809"></a><p class="title"><b>Example&nbsp;8.7.&nbsp;Invalid comment example</b></p><pre class="programlisting">
3686
3719
    SELECT count(*) FROM
3687
3720
    /* atable */
3688
3721
    btable;</pre></div><p>
3696
3729
                If they occur within an SQL Statment, SqlTool will pass them to
3697
3730
                the database engine, and the DB engine will determine whether
3698
3731
                to parse them as comments.
3699
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N117F3"></a>Special Commands and Buffer Commands in SQL Files</h3></div></div><div></div></div><p>
 
3732
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1181B"></a>Special Commands and Buffer Commands in SQL Files</h3></div></div><div></div></div><p>
3700
3733
                Don't use Buffer Commands in your sql files, because they won't 
3701
3734
                work.
3702
3735
                Buffer Commands are for interactive use only.
3806
3839
                        your interactive shell or in the SQL files.
3807
3840
                        Only you know whether errors in your SQL files can
3808
3841
                        safely be ignored.
3809
 
                    </p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
3810
 
                        In previous versions of SqlTool, this special command
3811
 
                        was "\*".  This usage is still supported, but is
3812
 
                        deprecated.  It was changed because "\*" is a very
3813
 
                        poor mnemonic.
3814
 
                        Even the author of the program had to constantly 
3815
 
                        look up whether "\* true" meant to Continue on
3816
 
                        error or to Abort upon error.
3817
 
                        Now, the "c" signifies <span class="emphasis"><em>Continue</em></span>.
3818
 
                    </p></div></dd></dl></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1185E"></a>Automation</h3></div></div><div></div></div><p>
 
3842
                    </p></div></dd></dl></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11880"></a>Automation</h3></div></div><div></div></div><p>
3819
3843
                SqlTool is ideal for mission-critical automation because,
3820
3844
                unlike other SQL tools, SqlTool returns a dependable exit 
3821
3845
                status and gives you control over error handling and SQL 
3830
3854
                database input and output as well as for many other purposes.
3831
3855
                See the <a href="#pl-section" title="SqlTool Procedural Language">SqlTool Procedural Language</a>
3832
3856
                section.
3833
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11869"></a>Getting Interactive Functionality with SQL Files</h3></div></div><div></div></div><p>
 
3857
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1188B"></a>Getting Interactive Functionality with SQL Files</h3></div></div><div></div></div><p>
3834
3858
                Some script developers may run into cases where they want to 
3835
3859
                run with sql files but they alwo want SqlTool's interactive 
3836
3860
                behavior.
3851
3875
                You can use another character set by setting the system 
3852
3876
                property <span class="property">sqlfile.charset</span>, like
3853
3877
            <div class="informalexample"><pre class="screen">
3854
 
java -Dsqlfile.charset=UTF-8 -jar $HSQLDB_HOME/lib/hsqldb.jar urlid filepath1.sql...</pre></div></p><p>
 
3878
java -Dsqlfile.charset=UTF-8 -jar $HSQLDB_HOME/lib/hsqldb.jar urlid file.sql...</pre></div></p><p>
3855
3879
                You can also set this per urlid in the SqlTool configuration 
3856
3880
                file.
3857
3881
                See the <a href="#auth-section" title="RC File Authentication Setup">RC File Authentication Setup</a>
3937
3961
            variable expansion.
3938
3962
            People who don't use PL don't have to worry about strings getting
3939
3963
            accidentally expanded.
3940
 
        </p><p> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
3941
 
                Users of previous versions of SqlFile should notice that
3942
 
                whitespace is no longer required after the *
3943
 
                (though you may use whitespace there if you wish).
3944
 
        </div> </p><p>
 
3964
        </p><p>
3945
3965
            All other PL commands imply the "*" command, so you only need to 
3946
3966
            use the "*" statement if your script uses PL variables
3947
3967
            and it is possible that no variables may be set before-hand (and
3959
3979
            This is explained above in the Interactive
3960
3980
            <a href="#interactive_pl_commands-section" title="PL Commands">Essential PL Command</a>
3961
3981
            section above.
3962
 
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N118F8"></a>Variables</h3></div></div><div></div></div><div class="itemizedlist"><ul type="disc"><li>
 
3982
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11915"></a>Variables</h3></div></div><div></div></div><div class="itemizedlist"><ul type="disc"><li>
3963
3983
                    Use the <tt class="literal">* list</tt> command to list some or
3964
3984
                    all variables; or <tt class="literal">* listvalue</tt> to also
3965
3985
                    see the values.
4038
4058
        </p></div><p>
4039
4059
                Here is a short SQL file that gives the specified user write
4040
4060
                permissions on some application tables.
4041
 
            </p><div class="example"><a name="N11968"></a><p class="title"><b>Example&nbsp;8.8.&nbsp;Simple SQL file using PL</b></p><pre class="programlisting">
 
4061
            </p><div class="example"><a name="N11985"></a><p class="title"><b>Example&nbsp;8.8.&nbsp;Simple SQL file using PL</b></p><pre class="programlisting">
4042
4062
    /*
4043
4063
       grantwrite.sql
4044
4064
 
4067
4087
                (This would not be necessary if the USER variable, or any
4068
4088
                other variable, were set, but we don't want to depend upon 
4069
4089
                that).
4070
 
            </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11976"></a>Logical Expressions</h3></div></div><div></div></div><p>
 
4090
            </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11993"></a>Logical Expressions</h3></div></div><div></div></div><p>
4071
4091
                Logical expressions occur only inside of logical expression
4072
4092
                parentheses in PL statements.
4073
4093
                For example, <tt class="literal">if (*var1 &gt; astring)</tt> and
4130
4150
                expressions as you expect.
4131
4151
                Just run <tt class="literal">* if</tt> commands that print something
4132
4152
                (i.e. \p) if the test expression is true.
4133
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N119EF"></a>Flow Control</h3></div></div><div></div></div><p>
 
4153
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11A0C"></a>Flow Control</h3></div></div><div></div></div><p>
4134
4154
                Flow control works by conditionally executing blocks of 
4135
4155
                Commands according to conditions specified by logical 
4136
4156
                expressions.
4183
4203
            name <tt class="filename">pl.sql</tt>.
4184
4204
            Definitely give it a run, like <pre class="screen">
4185
4205
java -jar $HSQLDB_HOME/lib/hsqldb.jar mem $HSQLDB_HOME/src/org/hsqldb/sample/pl.jar</pre>
4186
 
        </p><div class="example"><a name="N11A31"></a><p class="title"><b>Example&nbsp;8.9.&nbsp;SQL File showing use of most PL features</b></p><pre class="programlisting">/*
 
4206
        </p><div class="example"><a name="N11A4E"></a><p class="title"><b>Example&nbsp;8.9.&nbsp;SQL File showing use of most PL features</b></p><pre class="programlisting">/*
4187
4207
    $Id: pl.sql,v 1.4 2005/05/02 15:07:26 unsaved Exp $
4188
4208
    SQL File to illustrate the use of SqlTool PL features.
4189
4209
    Invoke like
4288
4308
            applies to any JDBC client.
4289
4309
            There are, however, situations where you don't need immediate
4290
4310
            feedback from every SQL command.  For example,
4291
 
        <div class="example"><a name="N11A46"></a><p class="title"><b>Example&nbsp;8.10.&nbsp;Single-line chunking example</b></p><pre class="screen">
 
4311
        <div class="example"><a name="N11A63"></a><p class="title"><b>Example&nbsp;8.10.&nbsp;Single-line chunking example</b></p><pre class="screen">
4292
4312
    INSERT INTO t1 VALUES(0); SELECT * FROM t1;</pre></div>
4293
4313
            It's useful because the output of the second SQL command will tell
4294
4314
            you whether the first SQL command succeeded.  So, you won't miss
4295
4315
            the status output from the first command.
4296
 
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11A4D"></a>Why?</h3></div></div><div></div></div><p>
 
4316
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11A6A"></a>Why?</h3></div></div><div></div></div><p>
4297
4317
                The first general reason to chunk SQL commands is performance.
4298
4318
                For standalone databases, the most common performance 
4299
4319
                bottleneck is network latency.
4305
4325
                This is often the case when you need to tell the database
4306
4326
                the SQL or PL/SQL commands that comprise a stored procedure,
4307
4327
                function, trigger, etc.
4308
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11A54"></a>How?</h3></div></div><div></div></div><p>
 
4328
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11A71"></a>How?</h3></div></div><div></div></div><p>
4309
4329
                The most simple way is enter as many SQL commands as you 
4310
4330
                want, but just do not end a line with ";" until you want
4311
4331
                the chunk to transmit.
4312
 
                <div class="example"><a name="N11A59"></a><p class="title"><b>Example&nbsp;8.11.&nbsp;Multi-line chunking example</b></p><pre class="screen">
 
4332
                <div class="example"><a name="N11A76"></a><p class="title"><b>Example&nbsp;8.11.&nbsp;Multi-line chunking example</b></p><pre class="screen">
4313
4333
    INSERT INTO t1 VALUES (1)
4314
4334
    ; INSERT INTO t1 VALUES (2)
4315
4335
    ; SELECT * FROM t1;</pre></div>
4345
4365
            What you will normally want to do is to enter the Buffer Command
4346
4366
            ":;" to transmit the buffer to the database engine.
4347
4367
        </p><p>
4348
 
            <div class="example"><a name="N11A78"></a><p class="title"><b>Example&nbsp;8.12.&nbsp;Raw Mode example</b></p><pre class="screen">
 
4368
            <div class="example"><a name="N11A95"></a><p class="title"><b>Example&nbsp;8.12.&nbsp;Raw Mode example</b></p><pre class="screen">
4349
4369
    sql&gt; \.
4350
4370
    Enter RAW SQL.  No \, :, * commands.  End with a line containing only ".":
4351
4371
    raw&gt; line one;
4375
4395
            enabled for non-interactive use, because they are required for
4376
4396
            using raw mode, and it is definitely useful to be able to
4377
4397
            use raw mode in SQL files.
4378
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11A81"></a>PL/SQL</h2></div></div><div></div></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
 
4398
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11A9E"></a>PL/SQL</h2></div></div><div></div></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
4379
4399
            PL/SQL is <span class="bold"><b>not</b></span> the same as
4380
4400
            PL.  PL is the procedural language of SqlFile and is 
4381
4401
            independent of your back-end database.
4402
4422
            standard PL/SQL, if you have permission to create the table
4403
4423
            "T1" in the default schema, and if that object does not 
4404
4424
            already exist.
4405
 
            <div class="example"><a name="N11A9B"></a><p class="title"><b>Example&nbsp;8.13.&nbsp;PL/SQL Example</b></p><pre class="programlisting">/*
 
4425
            <div class="example"><a name="N11AB8"></a><p class="title"><b>Example&nbsp;8.13.&nbsp;PL/SQL Example</b></p><pre class="programlisting">/*
4406
4426
 * $Id: plsql.sql,v 1.3 2005/05/02 15:09:11 unsaved Exp $
4407
4427
 *
4408
4428
 * This example is copied from the "Simple Programs in PL/SQL"
4458
4478
            Note that, inside of raw mode, you can use any kind of formatting
4459
4479
            you want:  Whatever you enter--  blank lines, comments,
4460
4480
            everything-- will be transmitted to the database engine.
4461
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11AA2"></a>Using hsqltool.jar and hsqldbutil.jar</h2></div></div><div></div></div><p>
 
4481
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11ABF"></a>Using hsqltool.jar and hsqldbutil.jar</h2></div></div><div></div></div><p>
4462
4482
            This section is only for those users who want to use SqlTool
4463
4483
            but without the overhead of hsqldb.jar.
4464
4484
        </p><p>
4503
4523
            at the end of the
4504
4524
            <a href="#baremin-section" title="The Bare Minimum You Need to Know to Run SqlTool">The Bare Minimum</a> section,
4505
4525
            but use your new file in place of <tt class="filename">hsqldb.jar</tt>.
4506
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11AFB"></a>Unit Testing SqlTool</h2></div></div><div></div></div><p>
4507
 
            A unit testing framework is in place.
4508
 
            This assures the robustness of SqlTool.
4509
 
            See the file <tt class="filename">testrun/sqltool/readme.txt</tt>
4510
 
            for instructions on running, modifying, or creating unit
4511
 
            tests.
4512
 
            To create a new unit test, you create a SQL file and embed
4513
 
            metacommands in the SQL file inside of comments.
4514
 
            The metacommands tell the test harness
4515
 
            (<tt class="classname">org.hsqldb.test.SqlToolHarness</tt>)
4516
 
            how to run SqlTool (like with what arguments) and what
4517
 
            output to expect (i.e. the test criteria).
4518
 
            You can run tests without JUnit, or you can make a JUnit
4519
 
            wrapper in the normal fashion.  Any SQL test file can
4520
 
            be added to our JUnit SqlTool test suite by just adding
4521
 
            the SQL file name and description to the 
4522
 
            <tt class="filename">testrun/sqltool/*.list</tt> file for the 
4523
 
            desired JUnit test method.
4524
 
        </p><p>
4525
 
            (The SqlTool unit tests require java 1.4).
4526
 
        </p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="sqlsyntax-chapter"></a>Chapter&nbsp;9.&nbsp;SQL Syntax</h2></div><div><div class="authorgroup"><h3 class="corpauthor">The Hypersonic SQL Group</h3><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div><div class="author"><h3 class="author"><span class="firstname">Peter</span> <span class="surname">Hudson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div></div><div class="author"><h3 class="author"><span class="firstname">Joe</span> <span class="surname">Maher</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:jrmaher@ameritech.net">jrmaher@ameritech.net</a>&gt;</tt></div><h4 class="editedby">Edited by</h4><h3 class="editor"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3></div></div><div><p class="pubdate">$Date: 2005/06/30 22:39:11 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N11B4F">Notational Conventions Used in this Chapter</a></span></dt><dt><span class="section"><a href="#N11B6C">SQL Commands</a></span></dt><dd><dl><dt><span class="section"><a href="#alter_index-section">ALTER INDEX</a></span></dt><dt><span class="section"><a href="#alter_sequence-section">ALTER SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11B8B">ALTER SCHEMA</a></span></dt><dt><span class="section"><a href="#alter_table-section">ALTER TABLE</a></span></dt><dt><span class="section"><a href="#alter_user-section">ALTER USER</a></span></dt><dt><span class="section"><a href="#call-section">CALL</a></span></dt><dt><span class="section"><a href="#checkpoint-section">CHECKPOINT</a></span></dt><dt><span class="section"><a href="#commit-section">COMMIT</a></span></dt><dt><span class="section"><a href="#connect-section">CONNECT</a></span></dt><dt><span class="section"><a href="#create_alias-section">CREATE ALIAS</a></span></dt><dt><span class="section"><a href="#create_index-section">CREATE INDEX</a></span></dt><dt><span class="section"><a href="#create_role-section">CREATE ROLE</a></span></dt><dt><span class="section"><a href="#N11CA5">CREATE SCHEMA</a></span></dt><dt><span class="section"><a href="#create_sequence-section">CREATE SEQUENCE</a></span></dt><dt><span class="section"><a href="#create_table-section">CREATE TABLE</a></span></dt><dt><span class="section"><a href="#create_trigger-section">CREATE TRIGGER</a></span></dt><dt><span class="section"><a href="#create_user-section">CREATE USER</a></span></dt><dt><span class="section"><a href="#create_view-section">CREATE VIEW</a></span></dt><dt><span class="section"><a href="#delete-section">DELETE</a></span></dt><dt><span class="section"><a href="#disconnect-section">DISCONNECT</a></span></dt><dt><span class="section"><a href="#drop_index-section">DROP INDEX</a></span></dt><dt><span class="section"><a href="#N11E14">DROP ROLE</a></span></dt><dt><span class="section"><a href="#drop_sequence-section">DROP SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11E2E">DROP SCHEMA</a></span></dt><dt><span class="section"><a href="#drop_table-section">DROP TABLE</a></span></dt><dt><span class="section"><a href="#drop_trigger-section">DROP TRIGGER</a></span></dt><dt><span class="section"><a href="#drop_user-section">DROP USER</a></span></dt><dt><span class="section"><a href="#drop_view-section">DROP VIEW</a></span></dt><dt><span class="section"><a href="#explain-section">EXPLAIN PLAN</a></span></dt><dt><span class="section"><a href="#grant-section">GRANT</a></span></dt><dt><span class="section"><a href="#insert-section">INSERT</a></span></dt><dt><span class="section"><a href="#revoke-section">REVOKE</a></span></dt><dt><span class="section"><a href="#rollback-section">ROLLBACK</a></span></dt><dt><span class="section"><a href="#savepoint-section">SAVEPOINT</a></span></dt><dt><span class="section"><a href="#script-section">SCRIPT</a></span></dt><dt><span class="section"><a href="#select-section">SELECT</a></span></dt><dt><span class="section"><a href="#set_autocommit-section">SET AUTOCOMMIT</a></span></dt><dt><span class="section"><a href="#collation-section">SET DATABASE COLLATION</a></span></dt><dt><span class="section"><a href="#N11FBD">SET CHECKPOINT DEFRAG</a></span></dt><dt><span class="section"><a href="#set_ignorecase-section">SET IGNORECASE</a></span></dt><dt><span class="section"><a href="#set_logsize-section">SET LOGSIZE</a></span></dt><dt><span class="section"><a href="#set_password-section">SET PASSWORD</a></span></dt><dt><span class="section"><a href="#set_property-section">SET PROPERTY</a></span></dt><dt><span class="section"><a href="#set_refint-section">SET REFERENTIAL INTEGRITY</a></span></dt><dt><span class="section"><a href="#N1201E">SET SCHEMA</a></span></dt><dt><span class="section"><a href="#set_scriptformat-section">SET SCRIPTFORMAT</a></span></dt><dt><span class="section"><a href="#set_table_index-section">SET TABLE INDEX</a></span></dt><dt><span class="section"><a href="#set_table_readonly-section">SET TABLE READONLY</a></span></dt><dt><span class="section"><a href="#set_table_source-section">SET TABLE SOURCE</a></span></dt><dt><span class="section"><a href="#set_write_delay-section">SET WRITE DELAY</a></span></dt><dt><span class="section"><a href="#shutdown-section">SHUTDOWN</a></span></dt><dt><span class="section"><a href="#update-section">UPDATE</a></span></dt></dl></dd><dt><span class="section"><a href="#datatypes-section">Data Types</a></span></dt><dt><span class="section"><a href="#N12234">SQL Comments</a></span></dt><dt><span class="section"><a href="#stored-section">Stored Procedures / Functions</a></span></dt><dt><span class="section"><a href="#N12265">Built-in Functions and Stored Procedures</a></span></dt><dt><span class="section"><a href="#expression-section">SQL Expression</a></span></dt></dl></div><p>HSQLDB version 1.8.0 supports the SQL statements and syntax described
4527
 
  in this chapter.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11B4F"></a>Notational Conventions Used in this Chapter</h2></div></div><div></div></div><p><tt class="literal">[A]</tt> means A is optional.</p><p><tt class="literal">{ B | C }</tt> means either B or C must be
 
4526
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11B18"></a>Character-Separated-Value Imports and Exports</h2></div></div><div></div></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
 
4527
            These features were added for version 1.8.0.3 of HSQLDB.
 
4528
        </p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
 
4529
            This feature is independent of HSQLDB 
 
4530
            <a href="#texttables-chapter" title="Chapter&nbsp;6.&nbsp;Text Tables">Text Tables</a>,
 
4531
            a server-side feature of HSQLDB.
 
4532
            It makes no difference to SqlTool whether the source or target
 
4533
            table of your export/import is a memory, cache, or text table.
 
4534
            Indeed, like all features of SqlTool, it works fine with other
 
4535
            JDBC databases.
 
4536
            It works great, for example to migrate data from a table
 
4537
            of one type to a table of another type, or to another schema,
 
4538
            or to another database instance, or to another database system.
 
4539
        </p></div><p>
 
4540
            Because of common usage of the term, I call this feature
 
4541
            <span class="emphasis"><em>CSV</em></span> imports and exports, even though the
 
4542
            delimiters are not constrained to single characters, but
 
4543
            may be any String.
 
4544
            Use the <tt class="literal">\x</tt> command to eXport a table to a
 
4545
            CSV file, and the <tt class="literal">\m</tt> command to iMport a
 
4546
            CSV file into a pre-existing table.
 
4547
        </p><p>
 
4548
            Just as the delimiter capability is more general than traditional
 
4549
            CSV delimiters, the export function is also more general than
 
4550
            just a table data exporter.
 
4551
            Besides the trivial generalization that you may specify a
 
4552
            view or other virtual table name in place of a table name,
 
4553
            you can alternatively export the output of any query which 
 
4554
            produces normal text output.
 
4555
            A benefit to this approach is that it allows you to export only
 
4556
            some columns of a table, and to specify a WHERE clause to narrow 
 
4557
            down the rows to be exported (or perform any other SQL 
 
4558
            transformation, mapping, join, etc.).
 
4559
            One specific use for this would be to exclude columns of
 
4560
            binary data (which can be exported by other means, such as
 
4561
            a PL loop to store binary values to files with the \bd command).
 
4562
        </p><p>
 
4563
            Note that the import command will not create a new table.
 
4564
            This is because of the impossibility of guessing appropriate
 
4565
            types and constraints based only on column names and a data
 
4566
            sampling (which is all that a CSV-importer has access to).
 
4567
            Therefore, if you wish to populate a new table, create the
 
4568
            table before running the import.
 
4569
            The import file does not need to have data for all columns of a
 
4570
            table.
 
4571
            The only required columns are those required by non-null and
 
4572
            FK constraints.
 
4573
            One specific reason to omit columns is if you want values of
 
4574
            some columns to be created automatically by column DEFAULT
 
4575
            settings, triggers, HSQLDB identity sequences, etc.
 
4576
            Another reason would be to skip binary columns.
 
4577
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11B36"></a>Simple CSV exports and imports using default settings</h3></div></div><div></div></div><p>
 
4578
                Even if you need to change delimiters, table names, or file
 
4579
                names from the defaults, I suggest that you run one export
 
4580
                and import with default settings as a practice run.
 
4581
                A memory-only HSQLDB instance is ideal for test runs like this.
 
4582
            </p><p>
 
4583
                This command exports the table <tt class="literal">icf.projects</tt>
 
4584
                to the file <tt class="filename">projects.csv</tt> in the current
 
4585
                directory (where you invoked SqlTool from).
 
4586
                By default, the output file name will be the specified source
 
4587
                table name plus the extension <tt class="literal">.csv</tt>.
 
4588
                <div class="example"><a name="N11B49"></a><p class="title"><b>Example&nbsp;8.14.&nbsp;CSV Export Example</b></p><pre class="screen">    SET SCHEMA icf;
 
4589
    \x projects
 
4590
</pre></div>
 
4591
                We could also have run <tt class="literal">\x icf.projects</tt>
 
4592
                (which would have created a file named 
 
4593
                <tt class="filename">icf.projects.csv</tt>)
 
4594
                instead of changing the session schema.
 
4595
                In this example we have chosen to make the export file name
 
4596
                independent of the schema to facilitate importing it into
 
4597
                a different schema.
 
4598
            </p><p>
 
4599
                Take a look at the output file.
 
4600
                Notice that the first line consists of column names, not
 
4601
                data.
 
4602
                This line is present because it will be needed if the file is
 
4603
                to used for a CSV import.
 
4604
                Notice the following characterstics about the export data.
 
4605
                The column delimiter is the pipe character "|".
 
4606
                The record delimiter is the default line delimiter character(s)
 
4607
                for your operating system.
 
4608
                The string used to represent database <tt class="literal">NULL</tt>s
 
4609
                is <tt class="literal">[null]</tt>.
 
4610
                See the next section for how to change these from their default
 
4611
                values.
 
4612
            </p><p>
 
4613
                This command imports the data from the file
 
4614
                <tt class="filename">projects.csv</tt> in the current
 
4615
                directory (where you invoked SqlTool from) into the table
 
4616
                <tt class="literal">newschema.projects</tt>.
 
4617
                By default, the output table name will be the input filename
 
4618
                after removing optional leading directory and trailing final
 
4619
                extension.
 
4620
                <div class="example"><a name="N11B6C"></a><p class="title"><b>Example&nbsp;8.15.&nbsp;CSV Import Example</b></p><pre class="screen">    SET SCHEMA newschema;
 
4621
    \m projects.csv
 
4622
</pre></div>
 
4623
                If the CSV file was named with the target schema, you would
 
4624
                have skipped the <tt class="literal">SET SCHEMA</tt> command, like
 
4625
                <tt class="literal">\m newschema.projects.csv</tt>.
 
4626
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11B7B"></a>Specifying queries, delimiters, file names, table names,
 
4627
                columns</h3></div></div><div></div></div><p>
 
4628
                The header line in the CSV file is required at this time.
 
4629
                (If there is user demand, it can be made optional for
 
4630
                exporting, but it will remain required for importing).
 
4631
            </p><p>
 
4632
                Your export will fail if the column or record delimiter, or
 
4633
                the null representation value occurs in the data being
 
4634
                exported.
 
4635
                You change these values by setting the PL variables
 
4636
                <tt class="literal">*CSV_COL_DELIM</tt>,
 
4637
                <tt class="literal">*CSV_ROW_DELIM</tt>,
 
4638
                <tt class="literal">*CSV_NULL_REP</tt>.
 
4639
                Notice that the asterisk is part of the variable names, to
 
4640
                indicate that these variables are used by SqlTool internally.
 
4641
                You can use the escape sequences \n, \r, and \t in the
 
4642
                usual manner.
 
4643
                For example, to change the column delimiter to the tab character,
 
4644
                you would give the command
 
4645
                <div class="informalexample"><pre class="screen">
 
4646
    * *CSV_COL_DELIM = \t</pre></div>
 
4647
            </p><p>
 
4648
                For imports, you must always specify the source CSV file path.
 
4649
                If you want to <span class="emphasis"><em>export</em></span> to a different file 
 
4650
                than one in the current directory named according to the source
 
4651
                table, set the PL variable <tt class="literal">*CSV_FILEPATH</tt>,
 
4652
                like
 
4653
                <div class="informalexample"><pre class="screen">
 
4654
    * *CSV_FILEPATH = /tmp/dtbl.csv</pre></div>
 
4655
            </p><p>
 
4656
                For exports, you must always specify the source table name
 
4657
                or query.
 
4658
                If you want to <span class="emphasis"><em>import</em></span> to a table other 
 
4659
                than that derived from
 
4660
                the input CSV file name, set the PL variable
 
4661
                <tt class="literal">*CSV_TABLENAME</tt>.
 
4662
                The table name may contain a schema name prefix.
 
4663
            </p><p>
 
4664
                At this time, you must import all columns that have data in
 
4665
                the CSV file.
 
4666
                If there is demand to specify an optional list of columns to
 
4667
                import, I'll gladly add that feature.
 
4668
            </p><p>
 
4669
                You can specify a query instead of a tablename with the
 
4670
                \x command in order to filter or transform data from a table
 
4671
                or view, or to export the output of a join, etc.
 
4672
                You must set the PL variable <tt class="literal">*CSV_FILEPATH</tt>,
 
4673
                as explained above (since there is no table name from which to
 
4674
                automatically map a file name).
 
4675
                <div class="example"><a name="N11BB2"></a><p class="title"><b>Example&nbsp;8.16.&nbsp;CSV Export of an Arbitrary SELECT Statement</b></p><pre class="screen">    * *CSV_FILEPATH = outfile.txt
 
4676
    \x SELECT entrydate, 2 * aval "Double aval", modtime from bs.dtbl</pre></div>
 
4677
                Note that I specified the column label alias "Double aval"
 
4678
                so that the label for that column in the CSV file header will 
 
4679
                not be blank.
 
4680
            </p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="sqlsyntax-chapter"></a>Chapter&nbsp;9.&nbsp;SQL Syntax</h2></div><div><div class="authorgroup"><h3 class="corpauthor">The Hypersonic SQL Group</h3><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div><div class="author"><h3 class="author"><span class="firstname">Peter</span> <span class="surname">Hudson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div></div><div class="author"><h3 class="author"><span class="firstname">Joe</span> <span class="surname">Maher</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:jrmaher@ameritech.net">jrmaher@ameritech.net</a>&gt;</tt></div><h4 class="editedby">Edited by</h4><h3 class="editor"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3></div></div><div><p class="pubdate">$Date: 2005/11/06 22:13:26 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N11BFC">Notational Conventions Used in this Chapter</a></span></dt><dt><span class="section"><a href="#N11C19">SQL Commands</a></span></dt><dd><dl><dt><span class="section"><a href="#alter_index-section">ALTER INDEX</a></span></dt><dt><span class="section"><a href="#alter_sequence-section">ALTER SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11C38">ALTER SCHEMA</a></span></dt><dt><span class="section"><a href="#alter_table-section">ALTER TABLE</a></span></dt><dt><span class="section"><a href="#alter_user-section">ALTER USER</a></span></dt><dt><span class="section"><a href="#call-section">CALL</a></span></dt><dt><span class="section"><a href="#checkpoint-section">CHECKPOINT</a></span></dt><dt><span class="section"><a href="#commit-section">COMMIT</a></span></dt><dt><span class="section"><a href="#connect-section">CONNECT</a></span></dt><dt><span class="section"><a href="#create_alias-section">CREATE ALIAS</a></span></dt><dt><span class="section"><a href="#create_index-section">CREATE INDEX</a></span></dt><dt><span class="section"><a href="#create_role-section">CREATE ROLE</a></span></dt><dt><span class="section"><a href="#N11D63">CREATE SCHEMA</a></span></dt><dt><span class="section"><a href="#create_sequence-section">CREATE SEQUENCE</a></span></dt><dt><span class="section"><a href="#create_table-section">CREATE TABLE</a></span></dt><dt><span class="section"><a href="#create_trigger-section">CREATE TRIGGER</a></span></dt><dt><span class="section"><a href="#create_user-section">CREATE USER</a></span></dt><dt><span class="section"><a href="#create_view-section">CREATE VIEW</a></span></dt><dt><span class="section"><a href="#delete-section">DELETE</a></span></dt><dt><span class="section"><a href="#disconnect-section">DISCONNECT</a></span></dt><dt><span class="section"><a href="#drop_index-section">DROP INDEX</a></span></dt><dt><span class="section"><a href="#N11ED7">DROP ROLE</a></span></dt><dt><span class="section"><a href="#drop_sequence-section">DROP SEQUENCE</a></span></dt><dt><span class="section"><a href="#N11EF1">DROP SCHEMA</a></span></dt><dt><span class="section"><a href="#drop_table-section">DROP TABLE</a></span></dt><dt><span class="section"><a href="#drop_trigger-section">DROP TRIGGER</a></span></dt><dt><span class="section"><a href="#drop_user-section">DROP USER</a></span></dt><dt><span class="section"><a href="#drop_view-section">DROP VIEW</a></span></dt><dt><span class="section"><a href="#explain-section">EXPLAIN PLAN</a></span></dt><dt><span class="section"><a href="#grant-section">GRANT</a></span></dt><dt><span class="section"><a href="#insert-section">INSERT</a></span></dt><dt><span class="section"><a href="#revoke-section">REVOKE</a></span></dt><dt><span class="section"><a href="#rollback-section">ROLLBACK</a></span></dt><dt><span class="section"><a href="#savepoint-section">SAVEPOINT</a></span></dt><dt><span class="section"><a href="#script-section">SCRIPT</a></span></dt><dt><span class="section"><a href="#select-section">SELECT</a></span></dt><dt><span class="section"><a href="#set_autocommit-section">SET AUTOCOMMIT</a></span></dt><dt><span class="section"><a href="#collation-section">SET DATABASE COLLATION</a></span></dt><dt><span class="section"><a href="#N1208B">SET CHECKPOINT DEFRAG</a></span></dt><dt><span class="section"><a href="#set_ignorecase-section">SET IGNORECASE</a></span></dt><dt><span class="section"><a href="#set_initialschema-section">SET INITIAL SCHEMA </a></span></dt><dt><span class="section"><a href="#set_logsize-section">SET LOGSIZE</a></span></dt><dt><span class="section"><a href="#set_password-section">SET PASSWORD</a></span></dt><dt><span class="section"><a href="#set_property-section">SET PROPERTY</a></span></dt><dt><span class="section"><a href="#set_refint-section">SET REFERENTIAL INTEGRITY</a></span></dt><dt><span class="section"><a href="#set_schema-section">SET SCHEMA</a></span></dt><dt><span class="section"><a href="#set_scriptformat-section">SET SCRIPTFORMAT</a></span></dt><dt><span class="section"><a href="#set_table_index-section">SET TABLE INDEX</a></span></dt><dt><span class="section"><a href="#set_table_readonly-section">SET TABLE READONLY</a></span></dt><dt><span class="section"><a href="#set_table_source-section">SET TABLE SOURCE</a></span></dt><dt><span class="section"><a href="#set_write_delay-section">SET WRITE DELAY</a></span></dt><dt><span class="section"><a href="#shutdown-section">SHUTDOWN</a></span></dt><dt><span class="section"><a href="#update-section">UPDATE</a></span></dt></dl></dd><dt><span class="section"><a href="#schemanaming-section">Schema object naming</a></span></dt><dt><span class="section"><a href="#datatypes-section">Data Types</a></span></dt><dt><span class="section"><a href="#N12364">SQL Comments</a></span></dt><dt><span class="section"><a href="#stored-section">Stored Procedures / Functions</a></span></dt><dt><span class="section"><a href="#N12395">Built-in Functions and Stored Procedures</a></span></dt><dt><span class="section"><a href="#expression-section">SQL Expression</a></span></dt></dl></div><p>HSQLDB version 1.8.0 supports the SQL statements and syntax described
 
4681
  in this chapter.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11BFC"></a>Notational Conventions Used in this Chapter</h2></div></div><div></div></div><p><tt class="literal">[A]</tt> means A is optional.</p><p><tt class="literal">{ B | C }</tt> means either B or C must be
4528
4682
    used.</p><p><tt class="literal">[{ B | C }]</tt> means either B or C may optionally be
4529
4683
    used, or nothing at all.</p><p><tt class="literal">(</tt> and <tt class="literal">)</tt> are the actual
4530
 
    characters '(' and ')' used in statements.</p><p>UPPERCASE words are keywords</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11B6C"></a>SQL Commands</h2></div></div><div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_index-section"></a>ALTER INDEX<sup>[<a href="#ftn.posthyper" name="posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER INDEX &lt;indexname&gt; RENAME TO &lt;newname&gt;;</pre><p>Index names can be changed so long as they do not conflict with
4531
 
      other user-defined or sytem-defined names.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_sequence-section"></a>ALTER SEQUENCE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER SEQUENCE &lt;sequencename&gt; RESTART WITH &lt;value&gt;;</pre><p>Resets the next value to be returned from the sequence.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11B8B"></a>ALTER SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER SCHEMA &lt;schemaname&gt; RENAME TO &lt;newname&gt;;</pre><p>Renames schema as specified. All objects of the schema will
4532
 
      hereafter be accessible only with the new schema name.</p><p>Requires Administrative privileges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_table-section"></a>ALTER TABLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [COLUMN] &lt;columnname&gt; <a href="#datatypes-section" title="Data Types">Datatype</a> [(columnSize[,precision])]
4533
 
    [{DEFAULT &lt;defaultValue&gt; |
 
4684
    characters '(' and ')' used in statements.</p><p>UPPERCASE words are keywords</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11C19"></a>SQL Commands</h2></div></div><div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_index-section"></a>ALTER INDEX<sup>[<a href="#ftn.posthyper" name="posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER INDEX &lt;indexname&gt; RENAME TO &lt;newname&gt;;</pre><p>Index names can be changed so long as they do not conflict with
 
4685
      other user-defined or sytem-defined names.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_sequence-section"></a>ALTER SEQUENCE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER SEQUENCE &lt;sequencename&gt; RESTART WITH &lt;value&gt;;</pre><p>Resets the next value to be returned from the sequence.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11C38"></a>ALTER SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER SCHEMA &lt;schemaname&gt; RENAME TO &lt;newname&gt;;</pre><p>Renames the schema as specified. All objects of the schema will
 
4686
      hereafter be accessible only with the new schema name.</p><p>Requires Administrative privileges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_table-section"></a>ALTER TABLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [COLUMN] &lt;columnname&gt; <a href="#datatypes-section" title="Data Types">Datatype</a>
 
4687
    [(columnSize[,precision])] [{DEFAULT &lt;defaultValue&gt; |
4534
4688
    GENERATED BY DEFAULT AS IDENTITY (START WITH &lt;n&gt;[, INCREMENT BY &lt;m&gt;])}] |
4535
4689
    [[NOT] NULL] [IDENTITY] [PRIMARY KEY]
4536
4690
    [BEFORE &lt;existingcolumn&gt;];</pre><p>Adds the column to the end of the column list. The optional BEFORE
4555
4709
        (similar to previous item).</li><li>Depending on the type of change, the table may have to be
4556
4710
        empty for the command to work. It always works when the type of change
4557
4711
        is possible in general and the individual existing values can all be
4558
 
        converted.</li></ul></div><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ALTER COLUMN &lt;columnname&gt; RESTART WITH &lt;new sequence vale&gt;</pre><p>This form is used exclusively for IDENTITY columns and changes the
4559
 
      next automatic value for the identity sequence.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [CONSTRAINT &lt;constraintname&gt;] CHECK (&lt;search condition&gt;);</pre><p>Adds a check constraint to the table. In the current version, a
 
4712
        converted.</li></ul></div><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ALTER COLUMN &lt;columnname&gt;
 
4713
    RESTART WITH &lt;new sequence value&gt;</pre><p>This form is used exclusively for IDENTITY columns and changes the
 
4714
      next automatic value for the identity sequence.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [CONSTRAINT &lt;constraintname&gt;]
 
4715
    CHECK (&lt;search condition&gt;);</pre><p>Adds a check constraint to the table. In the current version, a
4560
4716
      check constraint can reference only the row being inserted or
4561
4717
      updated.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [CONSTRAINT &lt;constraintname&gt;] UNIQUE (&lt;column list&gt;);</pre><p>Adds a unique constraint to the table. This will not work if there
4562
4718
      is already a unique constraint covering exactly the same &lt;column
4563
4719
      list&gt;.</p><p>This will work only if the values of the column list for the
4564
 
      existing rows are unique or include a null value.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [CONSTRAINT &lt;constraintname&gt;] PRIMARY KEY (&lt;column list&gt;);</pre><p>Adds a primary key constraint to the table, using the same
 
4720
      existing rows are unique or include a null value.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [CONSTRAINT &lt;constraintname&gt;]
 
4721
    PRIMARY KEY (&lt;column list&gt;);</pre><p>Adds a primary key constraint to the table, using the same
4565
4722
      constraint syntax as when the primary key is specified in a table
4566
 
      definition.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; ADD [CONSTRAINT &lt;constraintname&gt;] FOREIGN KEY (&lt;column list&gt;) REFERENCES &lt;exptablename&gt; (&lt;column list&gt;)
 
4723
      definition.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt;
 
4724
    ADD [CONSTRAINT &lt;constraintname&gt;] FOREIGN KEY (&lt;column list&gt;)
 
4725
    REFERENCES &lt;exptablename&gt; (&lt;column list&gt;)
4567
4726
    [ON {DELETE | UPDATE} {CASCADE | SET DEFAULT | SET NULL}];</pre><p>Adds a foreign key constraint to the table, using the same
4568
4727
      constraint syntax as when the foreign key is specified in a table
4569
4728
      definition.</p><p>This will fail if for each existing row in the referring table, a
4570
4729
      matching row (with equal values for the column list) is not found in the
4571
4730
      referenced tables.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; DROP CONSTRAINT &lt;constraintname&gt;;</pre><p>Drop a named unique, check or foreign key constraint from the
4572
4731
      table.</p><pre class="programlisting">ALTER TABLE &lt;tablename&gt; RENAME TO &lt;newname&gt;;</pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="alter_user-section"></a>ALTER USER<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">ALTER USER &lt;username&gt; SET PASSWORD &lt;password&gt;;</pre><p>Changes the password for an existing user. Password must be double
4573
 
      quoted. Use "" for an empty password.</p><p>Only an administrator can do this.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="call-section"></a>CALL</h3></div></div><div></div></div><pre class="programlisting">CALL <a href="#expression-section" title="SQL Expression">Expression</a>;</pre><p>Any expression can be called like a stored procedure, including,
 
4732
      quoted. Use "" for an empty password.</p><p>DBA's may change users' base default schema name with the comand
 
4733
      <pre class="programlisting">ALTER USER &lt;username&gt; SET INITIAL SCHEMA &lt;schemaname&gt;;</pre>
 
4734
      This is the schema which database object names will resolve to for this
 
4735
      user, unless overridden as explained in <a href="#schemanaming-section" title="Schema object naming">Schema object naming</a>. For
 
4736
      reasons of backwards compatibility, the initial schema value will not be
 
4737
      persisted across database shutdowns until HSQLDB version 1.8.1. (I.e.,
 
4738
      INITIAL SCHEMA settings will be lost upon database shutdown with HSQLDB
 
4739
      versions lower than version 1.8.1).</p><p>Only an administrator may use these commands.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="call-section"></a>CALL</h3></div></div><div></div></div><pre class="programlisting">CALL <a href="#expression-section" title="SQL Expression">Expression</a>;</pre><p>Any expression can be called like a stored procedure, including,
4574
4740
      but not only Java stored procedures or functions. This command returns a
4575
4741
      ResultSet with one column and one row (the result) just like a SELECT
4576
4742
      statement with one row and one column.</p><p>See also: <a href="#stored-section" title="Stored Procedures / Functions">Stored Procedures / Functions</a>, <a href="#expression-section" title="SQL Expression">SQL Expression</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="checkpoint-section"></a>CHECKPOINT</h3></div></div><div></div></div><pre class="programlisting">CHECKPOINT [DEFRAG<sup>[<a href="#ftn.posthyper">1</a>]</sup>];</pre><p>Closes the database files, rewrites the script file, deletes the
4577
4743
      log file and opens the database.</p><p>If DEFRAG is specified, this command also shrinks the .data file
4578
4744
      to its minimal size.</p><p>See also: <a href="#shutdown-section" title="SHUTDOWN">SHUTDOWN</a>, <a href="#set_logsize-section" title="SET LOGSIZE">SET LOGSIZE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="commit-section"></a>COMMIT</h3></div></div><div></div></div><pre class="programlisting">COMMIT [WORK];</pre><p>Ends a transaction and makes the changes permanent.</p><p>See also: <a href="#rollback-section" title="ROLLBACK">ROLLBACK</a>, <a href="#set_autocommit-section" title="SET AUTOCOMMIT">SET AUTOCOMMIT</a>, <a href="#set_logsize-section" title="SET LOGSIZE">SET LOGSIZE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="connect-section"></a>CONNECT</h3></div></div><div></div></div><pre class="programlisting">CONNECT USER &lt;username&gt; PASSWORD &lt;password&gt;;</pre><p>Connects to the database as a different user. Password should be
4579
4745
      double quoted. Use "" for an empty password.</p><p>See also: <a href="#grant-section" title="GRANT">GRANT</a>,
4580
 
      <a href="#revoke-section" title="REVOKE">REVOKE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_alias-section"></a>CREATE ALIAS</h3></div></div><div></div></div><pre class="programlisting">CREATE ALIAS &lt;function&gt; FOR &lt;javaFunction&gt;;</pre><p>Creates an alias for a Java function. The function must be
4581
 
      accessible from the JVM in which the database runs. Example:</p><div class="informalexample"><pre class="programlisting">    CREATE ALIAS ABS FOR "java.lang.Math.abs";</pre></div><p>See also: <a href="#call-section" title="CALL">CALL</a>,
 
4746
      <a href="#revoke-section" title="REVOKE">REVOKE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_alias-section"></a>CREATE ALIAS</h3></div></div><div></div></div><pre class="programlisting">CREATE ALIAS &lt;function&gt; FOR &lt;javaFunction&gt;;</pre><p>Creates an alias for a static Java function to be used as a
 
4747
          <a href="#stored-section" title="Stored Procedures / Functions">Stored Procedure</a>.
 
4748
          The function must be accessible from the JVM in which the database 
 
4749
          runs. Example:</p><div class="informalexample"><pre class="programlisting">    CREATE ALIAS ABS FOR "java.lang.Math.abs";</pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
 
4750
          The CREATE ALIAS command just defines the alias.
 
4751
          It does not validate existence of the target method or its 
 
4752
          containing class.
 
4753
          To validate the alias, use it.
 
4754
      </p></div><p>See also: <a href="#call-section" title="CALL">CALL</a>,
4582
4755
      <a href="#stored-section" title="Stored Procedures / Functions">Stored Procedures / Functions</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_index-section"></a>CREATE INDEX</h3></div></div><div></div></div><pre class="programlisting">CREATE [UNIQUE] INDEX &lt;index&gt; ON &lt;table&gt; (&lt;column&gt; [DESC] [, ...]) [DESC];</pre><p>Creates an index on one or more columns in a table.</p><p>Creating an index on searched columns may improve performance. The
4583
4756
      qualifier DESC can be present for command compatibility with other
4584
4757
      databases but it has no effect. Unique indexes can be defined but this
4585
4758
      is deprecated. Use UNIQUE constraints instead. The name of an index must
4586
4759
      be unique within the whole database.</p><p>See also: <a href="#create_table-section" title="CREATE TABLE">CREATE TABLE</a>, <a href="#drop_index-section" title="DROP INDEX">DROP INDEX</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_role-section"></a>CREATE ROLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE ROLE &lt;rolename&gt;;</pre><p>Creates the named role with no members. Requires Administrative
4587
 
      privileges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11CA5"></a>CREATE SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE SCHEMA &lt;schemaname&gt; AUTHORIZATION DBA [&lt;createStatement&gt; [&lt;grantStatement&lt;] [...];</pre><p>Creates the named schema.</p><p>Optional (nested) CREATE and GRANT statements can be given only
 
4760
      privileges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11D63"></a>CREATE SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE SCHEMA &lt;schemaname&gt; AUTHORIZATION &lt;grantee&gt;
 
4761
    [&lt;createStatement&gt; [&lt;grantStatement&gt;] [...];</pre><p>Creates the named schema, with ownership of the specified
 
4762
      <span class="emphasis"><em>authorization</em></span>. The authorization grantee may be a
 
4763
      database user or a role.</p><p>Optional (nested) CREATE and GRANT statements can be given only
4588
4764
      for new objects in this new schema. Only the last nested statement
4589
4765
      should be terminated with a semicolon, because the first semicolon
4590
4766
      encountered after "CREATE SCHEMA" will end the CREATE SCHEMA command. In
4591
4767
      the example below, a new schema, ACCOUNTS, is created, then two tables
4592
4768
      and a view are added to this schma and some rights on these objects are
4593
4769
      granted.<div class="informalexample"><pre class="programlisting">    CREATE SCHEMA ACCOUNTS AUTHORIZATION DBA
4594
 
    CREATE TABLE AB(A INTEGER, ...)
4595
 
    CREATE TABLE CD(C CHAHR, ...)
4596
 
    CREATE VIEW VI AS SELECT ...
4597
 
    GRANT SELECT TO PUBLIC ON AB
4598
 
    GRANT SELECT TO JOE ON CD;
4599
 
</pre></div></p><p>Requires Administrative privileges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_sequence-section"></a>CREATE SEQUENCE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE SEQUENCE &lt;sequencename&gt; [AS {INTEGER | BIGINT}] [START WITH &lt;startvalue&gt;] [INCREMENT BY &lt;incrementvalue&gt;];</pre><p>Creates a sequence. The default type is INTEGER. The default start
 
4770
        CREATE TABLE AB(A INTEGER, ...)
 
4771
        CREATE TABLE CD(C CHAHR, ...)
 
4772
        CREATE VIEW VI AS SELECT ...
 
4773
        GRANT SELECT TO PUBLIC ON AB
 
4774
        GRANT SELECT TO JOE ON CD;
 
4775
</pre></div>
 
4776
        Note that this example consists of one CREATE SCHEMA statement which
 
4777
        is terminated by a semicolon.
 
4778
    </p><p>Requires Administrative privileges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_sequence-section"></a>CREATE SEQUENCE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE SEQUENCE &lt;sequencename&gt; [AS {INTEGER | BIGINT}]
 
4779
    [START WITH &lt;startvalue&gt;] [INCREMENT BY &lt;incrementvalue&gt;];</pre><p>Creates a sequence. The default type is INTEGER. The default start
4600
4780
      value is 0 and the increment 1. Negative values are not allowed. If a
4601
4781
      sequence goes beyond Integer.MAXVALUE or Long.MAXVALUE, the next result
4602
4782
      is determined by 2's complement arithmetic.</p><p>The next value for a sequence can be included in SELECT, INSERT
4603
4783
      and UPDATE statements as in the following example:</p><p>
4604
 
        <div class="informalexample"><pre class="programlisting">SELECT [...,] NEXT VALUE FOR &lt;sequencename&gt; [, ...] FROM &lt;tablename&gt;</pre></div>
 
4784
        <div class="informalexample"><pre class="programlisting">SELECT [...,] NEXT VALUE FOR &lt;sequencename&gt; [, ...] FROM &lt;tablename&gt;;</pre></div>
4605
4785
      </p><p>In the proposed SQL 200n and in the current version, there is no
4606
4786
      way of retreiving the last returned value of a sequence.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_table-section"></a>CREATE TABLE</h3></div></div><div></div></div><pre class="programlisting">CREATE [MEMORY | CACHED | [GLOBAL] TEMPORARY | TEMP <sup>[<a href="#ftn.posthyper">1</a>]</sup> | TEXT<sup>[<a href="#ftn.posthyper">1</a>]</sup>] TABLE &lt;name&gt;
4607
 
( &lt;columnDefinition&gt; [, ...] [, &lt;constraintDefinition&gt;...] ) [ON COMMIT {DELETE | PRESERVE} ROWS];</pre><p>Creates a tables in memory (default) or on disk and only cached in
 
4787
    ( &lt;columnDefinition&gt; [, ...] [, &lt;constraintDefinition&gt;...] )
 
4788
    [ON COMMIT {DELETE | PRESERVE} ROWS];</pre><p>Creates a tables in memory (default) or on disk and only cached in
4608
4789
      memory. If the database is all-in-memory, both MEMORY and CACHED forms
4609
4790
      of CREATE TABLE return a MEMORY table while the TEXT form is not
4610
 
      allowed.</p><div class="variablelist"><p class="title"><b>Components of a CREATE TABLE command</b></p><dl><dt><a name="columnDef-entry"></a><span class="term"><a name="columnDef-title"></a>columnDefinition</span></dt><dd><pre class="programlisting">    columnname <a href="#datatypes-section" title="Data Types">Datatype</a> [(columnSize[,precision])] [{DEFAULT &lt;defaultValue&gt; |
4611
 
    GENERATED BY DEFAULT AS IDENTITY (START WITH &lt;n&gt;[, INCREMENT BY &lt;m&gt;])}] |
 
4791
      allowed.</p><div class="variablelist"><p class="title"><b>Components of a CREATE TABLE command</b></p><dl><dt><a name="columnDef-entry"></a><span class="term"><a name="columnDef-title"></a>columnDefinition</span></dt><dd><pre class="programlisting">columnname <a href="#datatypes-section" title="Data Types">Datatype</a> [(columnSize[,precision])]
 
4792
    [{DEFAULT &lt;defaultValue&gt; |
 
4793
    GENERATED BY DEFAULT AS IDENTITY
 
4794
    (START WITH &lt;n&gt;[, INCREMENT BY &lt;m&gt;])}] |
4612
4795
    [[NOT] NULL] [IDENTITY] [PRIMARY KEY]</pre><p>Default values that are allowed are constant values or
4613
4796
            certain SQL datetime functions.</p><div class="itemizedlist"><p class="title"><b>Allowed Default Values in Column Definitions</b></p><ul type="disc"><li><p>For character column, a single-quoted string or NULL.
4614
4797
                The only SQL function that can be used is CURRENT_USER.</p></li><li><p>For datetime columns, a single-quoted DATE, TIME or
4623
4806
            WITH &lt;n&gt;) clause specifies the first value that will be
4624
4807
            used. The last inserted value into an identity column for a
4625
4808
            connection is available using the function IDENTITY(), for example
4626
 
            (where Id is the identity column):</p><div class="informalexample"><pre class="programlisting">    INSERT INTO Test (Id, Name) VALUES (NULL,'Test');
4627
 
    CALL IDENTITY();</pre></div></dd><dt><span class="term">constraintDefinition</span></dt><dd><pre class="programlisting">    [CONSTRAINT &lt;name&gt;]
 
4809
            (where Id is the identity column):</p><div class="informalexample"><pre class="programlisting">INSERT INTO Test (Id, Name) VALUES (NULL,'Test');
 
4810
    CALL IDENTITY();</pre></div></dd><dt><span class="term">constraintDefinition</span></dt><dd><pre class="programlisting">[CONSTRAINT &lt;name&gt;]
4628
4811
    UNIQUE ( &lt;column&gt; [,&lt;column&gt;...] ) |
4629
4812
    PRIMARY KEY ( &lt;column&gt; [,&lt;column&gt;...] ) |
4630
 
    FOREIGN KEY ( &lt;column&gt; [,&lt;column&gt;...] ) REFERENCES &lt;refTable&gt; ( &lt;column&gt; [,&lt;column&gt;...]) 
4631
 
    [ON {DELETE | UPDATE} {CASCADE | SET DEFAULT | SET NULL}]<sup>[<a href="#ftn.posthyper">1</a>]</sup> |
 
4813
    FOREIGN KEY ( &lt;column&gt; [,&lt;column&gt;...] )
 
4814
    REFERENCES &lt;refTable&gt; ( &lt;column&gt; [,&lt;column&gt;...]) 
 
4815
    [ON {DELETE | UPDATE}
 
4816
    {CASCADE | SET DEFAULT | SET NULL}]<sup>[<a href="#ftn.posthyper">1</a>]</sup> |
4632
4817
    CHECK(&lt;search condition&gt;)<sup>[<a href="#ftn.posthyper">1</a>]</sup></pre><p>Both ON DELETE and ON UPDATE clauses can be used in a single
4633
4818
            foreign key definition.</p></dd><dt><span class="term">search condition</span></dt><dd><p>A search condition is similar to the set of conditions in a
4634
4819
            WHERE clause. In the current version of HSQLDB, the conditions for
4649
4834
            emptied by default at each commit or rollback. The optional
4650
4835
            qualifier ON COMMIT PRESERVE ROWS can be used to keep the rows
4651
4836
            while the session is open. The default is ON COMMIT DELETE
4652
 
            ROWS.</p></dd></dl></div><p>See also: <a href="#drop_table-section" title="DROP TABLE">DROP TABLE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_trigger-section"></a>CREATE TRIGGER<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE TRIGGER &lt;name&gt; {BEFORE | AFTER} {INSERT | UPDATE | DELETE} ON &lt;table&gt; [FOR EACH ROW] [QUEUE n] [NOWAIT] CALL &lt;TriggerClass&gt;;</pre><p>TriggerClass is an application-supplied class that implements the
 
4837
            ROWS.</p></dd></dl></div><p>See also: <a href="#drop_table-section" title="DROP TABLE">DROP TABLE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_trigger-section"></a>CREATE TRIGGER<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE TRIGGER &lt;name&gt; {BEFORE | AFTER} {INSERT | UPDATE | DELETE} ON &lt;table&gt;
 
4838
    [FOR EACH ROW] [QUEUE n] [NOWAIT] CALL &lt;TriggerClass&gt;;</pre><p>TriggerClass is an application-supplied class that implements the
4653
4839
      <tt class="classname">org.hsqldb.Trigger</tt> interface e.g.
4654
4840
      "mypackage.TrigClass". It is the fire method of this class that is
4655
4841
      invoked when the trigger event occurs. You should provide this class,
4662
4848
      mapping of members of the row arrays to database types is specified in
4663
4849
      <a href="#datatypes-section" title="Data Types">Data Types</a>. For
4664
4850
      example, BIGINT is represented by a <tt class="filename">java.lang.Long
4665
 
      Object</tt>. Note that the number of elements in the row arrays is
4666
 
      larger than the number of columns by one or two elements. Never modify
4667
 
      the last elements of the array, which are not part of the actual
 
4851
      Object</tt>. Note that the number of elements in the row arrays
 
4852
      could be larger than the number of columns by one or two elements. Never
 
4853
      modify the last elements of the array, which are not part of the actual
4668
4854
      row.</p><p>If the trigger method wants to access the database, it must
4669
4855
      establish its own JDBC connection. This can cause data inconsistency and
4670
4856
      other problems so it is not recommended. The
4706
4892
          <tt class="classname">org.hsqldb.sample.TriggerSample</tt>
4707
4893
        </a> for more information on how to write a trigger class.</p><p>See also: <a href="#drop_trigger-section" title="DROP TRIGGER">DROP TRIGGER</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_user-section"></a>CREATE USER</h3></div></div><div></div></div><pre class="programlisting">CREATE USER &lt;username&gt; PASSWORD &lt;password&gt; [ADMIN];</pre><p>Creates a new user or new administrator in this database. Password
4708
4894
      must be double quoted. Empty password can be made using "". You can
4709
 
      change a password afterwards using a <a href="#alter_user-section" title="ALTER USER">ALTER USER<sup>[<a href="#ftn.posthyper">1</a>]</sup></a> command.</p><p>Only an administrator can do this.</p><p>See also: <a href="#connect-section" title="CONNECT">CONNECT</a>, <a href="#grant-section" title="GRANT">GRANT</a>, <a href="#revoke-section" title="REVOKE">REVOKE</a>. <a href="#alter_user-section" title="ALTER USER">ALTER USER<sup>[<a href="#ftn.posthyper">1</a>]</sup></a>,</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_view-section"></a>CREATE VIEW<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE VIEW &lt;viewname&gt;[(&lt;viewcolumn&gt;,..) AS SELECT ... FROM ... [WHERE Expression];
 
4895
      change a password afterwards using a <a href="#alter_user-section" title="ALTER USER">ALTER USER<sup>[<a href="#ftn.posthyper">1</a>]</sup></a> command.</p><p>Only an administrator can do this.</p><p>See also: <a href="#connect-section" title="CONNECT">CONNECT</a>, <a href="#grant-section" title="GRANT">GRANT</a>, <a href="#revoke-section" title="REVOKE">REVOKE</a>. <a href="#alter_user-section" title="ALTER USER">ALTER USER<sup>[<a href="#ftn.posthyper">1</a>]</sup></a>,</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="create_view-section"></a>CREATE VIEW<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">CREATE VIEW &lt;viewname&gt;[(&lt;viewcolumn&gt;,..) AS SELECT ... FROM ... [WHERE Expression]
4710
4896
[ORDER BY orderExpression [, ...]]
4711
4897
[LIMIT &lt;limit&gt; [OFFSET &lt;offset&gt;]];</pre><p>A view can be thought of as either a virtual table or a stored
4712
4898
      query. The data accessible through a view is not stored in the database
4746
4932
      when using the JDBC interface: it is called automatically when the
4747
4933
      connection is closed. After disconnecting, it is not possible to execute
4748
4934
      other queries (including CONNECT) with this connection.</p><p>See also: <a href="#connect-section" title="CONNECT">CONNECT</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="drop_index-section"></a>DROP INDEX</h3></div></div><div></div></div><pre class="programlisting">DROP INDEX index [IF EXISTS];</pre><p>Removes the specified index from the database. Will not work if
4749
 
      the index backs a UNIQUE of FOREIGN KEY constraint.</p><p>See also: <a href="#create_index-section" title="CREATE INDEX">CREATE INDEX</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11E14"></a>DROP ROLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">DROP ROLE &lt;rolename&gt;;</pre><p>Removes all members from specified role, then removes the role
 
4935
      the index backs a UNIQUE of FOREIGN KEY constraint.</p><p>See also: <a href="#create_index-section" title="CREATE INDEX">CREATE INDEX</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11ED7"></a>DROP ROLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">DROP ROLE &lt;rolename&gt;;</pre><p>Removes all members from specified role, then removes the role
4750
4936
      itself.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="drop_sequence-section"></a>DROP SEQUENCE<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">DROP SEQUENCE &lt;sequencename&gt; [IF EXISTS] [RESTRICT | CASCADE];</pre><p>Removes the specified sequence from the database. When IF EXIST is
4751
4937
      used, the statement returns without an error if the sequence does not
4752
4938
      exist. The RESTRICT option is in effect by default, meaning that DROP
4753
4939
      will fail if any view reference the sequence. Specify the
4754
4940
      <tt class="literal">CASCADE</tt> option to silently drop all dependent
4755
 
      database objects.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11E2E"></a>DROP SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">DROP SCHEMA &lt;schemaname&gt; [RESTRICT | CASCADE];</pre><p>Removes the specified schema from the database. The RESTRICT
 
4941
      database objects.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11EF1"></a>DROP SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">DROP SCHEMA &lt;schemaname&gt; [RESTRICT | CASCADE];</pre><p>Removes the specified schema from the database. The RESTRICT
4756
4942
      option is in effect by default, meaning that DROP will fail if any
4757
4943
      objects such as tables or sequences have been defined in the schema.
4758
4944
      Specify the <tt class="literal">CASCADE</tt> option to silently drop all
4773
4959
ON { table | CLASS "package.class" } TO &lt;grantee&gt;;</pre><pre class="programlisting">GRANT &lt;rolename&gt; [,...] TO &lt;grantee&gt;<sup>[<a href="#ftn.posthyper">1</a>]</sup>;</pre><p>&lt;grantee&gt; is either a user name, a role name, or
4774
4960
      <tt class="literal">PUBLIC</tt>. <tt class="literal">PUBLIC</tt> means <span class="emphasis"><em>all
4775
4961
      users</em></span>.</p><p>The first form of the GRANT command assigns privileges to a
4776
 
      grantee for a table or for a class. To allow a user to call a function
4777
 
      from a class, the right ALL must be used. Examples: <div class="informalexample"><pre class="programlisting">    GRANT SELECT ON Test TO GUEST;
4778
 
    GRANT ALL ON CLASS "java.lang.String" TO PUBLIC;</pre></div></p><p>The second form of the GRANT command gives the specified
4779
 
      &lt;grantee&gt; membership in the specified role.</p><p>Require Administrative privileges.</p><p>See also: <a href="#revoke-section" title="REVOKE">REVOKE</a>, <a href="#create_user-section" title="CREATE USER">CREATE USER</a>, <a href="#create_role-section" title="CREATE ROLE">CREATE ROLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="insert-section"></a>INSERT</h3></div></div><div></div></div><pre class="programlisting">INSERT INTO table [( column [,...] )]
 
4962
      grantee for a table or for a class. To allow a user to call a 
 
4963
      <a href="#stored-section" title="Stored Procedures / Functions">Store Procedure</a> static
 
4964
      function, the right ALL must be used. Examples: <div class="informalexample"><pre class="programlisting">    GRANT SELECT ON Test TO GUEST;
 
4965
    GRANT ALL ON CLASS "java.lang.Math.abs" TO PUBLIC;</pre></div></p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
 
4966
          Even though the command is GRANT ALL ON CLASS, you must
 
4967
          specify a static <span class="emphasis"><em>method name</em></span>.  You are actually
 
4968
          granting access to a static method, not to a class.
 
4969
      </p></div><p>The second form of the GRANT command gives the specified
 
4970
      &lt;grantee&gt; membership in the specified role.</p><p>Requires Administrative privileges.</p><p>See also: <a href="#revoke-section" title="REVOKE">REVOKE</a>, <a href="#create_user-section" title="CREATE USER">CREATE USER</a>, <a href="#create_role-section" title="CREATE ROLE">CREATE ROLE<sup>[<a href="#ftn.posthyper">1</a>]</sup></a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="insert-section"></a>INSERT</h3></div></div><div></div></div><pre class="programlisting">INSERT INTO table [( column [,...] )]
4780
4971
{ VALUES(<a href="#expression-section" title="SQL Expression">Expression</a> [,...]) | <a href="#select-section" title="SELECT">SelectStatement</a>};</pre><p>Adds one or more new rows of data into a table.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="revoke-section"></a>REVOKE</h3></div></div><div></div></div><pre class="programlisting">REVOKE { SELECT | DELETE | INSERT | UPDATE | ALL } [,...]
4781
4972
ON { table | CLASS "package.class" } FROM &lt;grantee&gt;;</pre><pre class="programlisting">REVOKE &lt;rolename&gt; [,...] FROM &lt;grantee&gt;<sup>[<a href="#ftn.posthyper">1</a>]</sup>;</pre><p>&lt;grantee&gt; is either a user name, a role name, or
4782
4973
      <tt class="literal">PUBLIC</tt>. <tt class="literal">PUBLIC</tt> means <span class="emphasis"><em>all
4795
4986
[WHERE <a href="#expression-section" title="SQL Expression">Expression</a>]
4796
4987
[GROUP BY Expression [, ...]]
4797
4988
[HAVING Expression]
4798
 
[{ UNION [ALL | DISTINCT] | {MINUS [DISTINCT] | EXCEPT [DISTINCT] } | INTERSECT [DISTINCT] } selectStatement]
 
4989
[{ UNION [ALL | DISTINCT] | {MINUS [DISTINCT] | EXCEPT [DISTINCT] } |
 
4990
INTERSECT [DISTINCT] } selectStatement]
4799
4991
[ORDER BY orderExpression [, ...]]
4800
4992
[LIMIT &lt;limit&gt; [OFFSET &lt;offset&gt;]];</pre><p>Retrieves information from one or more tables in the
4801
 
      database.</p><div class="variablelist"><p class="title"><b>Components of a SELECT command</b></p><dl><dt><span class="term">tableList</span></dt><dd><pre class="programlisting">    table [{CROSS | INNER | LEFT OUTER | RIGHT OUTER} JOIN table ON Expression] [, ...]</pre></dd><dt><span class="term">table</span></dt><dd><pre class="programlisting">    { (selectStatement) [AS] label | tableName}</pre></dd><dt><span class="term">selectExpression</span></dt><dd><pre class="programlisting">    { Expression | COUNT(*) | {COUNT | MIN | MAX | SUM | AVG | SOME | EVERY | VAR_POP | VAR_SAMP | STDDEV_POP | STDDEV_SAMP} ([ALL | DISTINCT]<sup>[<a href="#ftn.posthyper">1</a>]</sup>] Expression) } [[AS] label]</pre><p>If DISTINCT is specified, only one instance of several
 
4993
      database.</p><div class="variablelist"><p class="title"><b>Components of a SELECT command</b></p><dl><dt><span class="term">tableList</span></dt><dd><pre class="programlisting">table [{CROSS | INNER | LEFT OUTER | RIGHT OUTER}
 
4994
    JOIN table ON Expression] [, ...]</pre></dd><dt><span class="term">table</span></dt><dd><pre class="programlisting">{ (selectStatement) [AS] label | tableName}</pre></dd><dt><span class="term">selectExpression</span></dt><dd><pre class="programlisting">{ Expression | COUNT(*) | {
 
4995
    COUNT | MIN | MAX | SUM | AVG | SOME | EVERY |
 
4996
    VAR_POP | VAR_SAMP | STDDEV_POP | STDDEV_SAMP
 
4997
} ([ALL | DISTINCT]<sup>[<a href="#ftn.posthyper">1</a>]</sup>] Expression) } [[AS] label]</pre><p>If DISTINCT is specified, only one instance of several
4802
4998
            equivalent values is used in the aggregate function. Except
4803
4999
            COUNT(*), all aggregate functions exclude NULL values. The type of
4804
5000
            the returned value for SUM is subject to deterministic widenning
4808
5004
            STDDEV_POP and STDDEV_SAMP statistical functions, the type is
4809
5005
            always DOUBLE. These statistical functions do not allow ALL or
4810
5006
            DISTINCT qualifiers.</p><p>If CROSS JOIN is specified no ON expression is allowed for
4811
 
            the join.</p></dd><dt><span class="term">orderExpression</span></dt><dd><pre class="programlisting">    { columnNr | columnAlias | selectExpression } [ASC | DESC]</pre></dd><dt><span class="term">LIMIT n m</span></dt><dd><p>Creates the result set for the SELECT statement first and
 
5007
            the join.</p></dd><dt><span class="term">orderExpression</span></dt><dd><pre class="programlisting">{ columnNr | columnAlias | selectExpression }
 
5008
    [ASC | DESC]</pre></dd><dt><span class="term">LIMIT n m</span></dt><dd><p>Creates the result set for the SELECT statement first and
4812
5009
            then discards the first n rows (OFFSET) and returns the first m
4813
5010
            rows of the remaining result set (LIMIT). Special cases: LIMIT 0 m
4814
5011
            is equivalent to TOP m or FIRST m in other RDBMS's; LIMIT n 0
4828
5025
      connections are in auto-commit mode. This command should not be used
4829
5026
      directly. Use the JDBC equivalent method,
4830
5027
      Connection.setAutoCommit(boolean autocommit).</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="collation-section"></a>SET DATABASE COLLATION<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">SET DATABASE COLLATION &lt;double quoted collation name&gt;;</pre><p>Each database can have its own collation. Sets the collation from
4831
 
      the set of collations in the source for org.hsqldb.Collation. Once this
4832
 
      command has been issued, the database can be opened in any JVM and will
4833
 
      retain its collation.</p><p>Once this command has been issued, the database can be opened in
4834
 
      any JVM and will retain its collation.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N11FBD"></a>SET CHECKPOINT DEFRAG<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">SET CHECKPOINT DEFRAG &lt;size&gt;;</pre><p>The parameter <tt class="literal">size</tt> is the megabytes of
 
5028
      the set of collations in the source for org.hsqldb.Collation.
 
5029
      </p><p>Once this command has been issued, the database can be opened in
 
5030
      any JVM and will retain its collation.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1208B"></a>SET CHECKPOINT DEFRAG<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">SET CHECKPOINT DEFRAG &lt;size&gt;;</pre><p>The parameter <tt class="literal">size</tt> is the megabytes of
4835
5031
      abandoned space in the .data file. When a CHECKPOINT is performed either
4836
5032
      as a result of the .log file reaching the limit set by "SET LOGSIZE
4837
5033
      size", or by the user issuing a CHECKPOINT command, the amount of space
4844
5040
      set to <tt class="literal">VARCHAR_IGNORECASE</tt> in new tables.
4845
5041
      Alternatively, you can specify the <tt class="literal">VARCHAR_IGNORECASE</tt>
4846
5042
      type for the definition of individual columns. So it is possible to have
4847
 
      some columns case sensitive and some not, even in the same table.</p><p>Only an administrator may do this.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="set_logsize-section"></a>SET LOGSIZE</h3></div></div><div></div></div><pre class="programlisting">SET LOGSIZE &lt;size&gt;;</pre><p>Sets the maximum size in MB of the .log file. Default is 200 MB.
 
5043
      some columns case sensitive and some not, even in the same table.</p><p>Only an administrator may do this.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="set_initialschema-section"></a>SET INITIAL SCHEMA <sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><p>Users may change their base default schema name with the comand
 
5044
      <pre class="programlisting">SET INITIAL SCHEMA &lt;schemaname&gt;;</pre>
 
5045
      This is the schema which database object names will resolve to for the
 
5046
      current user, unless overridden as explained in <a href="#schemanaming-section" title="Schema object naming">Schema object naming</a>. For
 
5047
      reasons of backwards compatibility, the initial schema value will not be
 
5048
      persisted across database shutdowns until HSQLDB version 1.8.1. (I.e.,
 
5049
      INITIAL SCHEMA settings will be lost upon database shutdown with HSQLDB
 
5050
      versions lower than version 1.8.1).</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="set_logsize-section"></a>SET LOGSIZE</h3></div></div><div></div></div><pre class="programlisting">SET LOGSIZE &lt;size&gt;;</pre><p>Sets the maximum size in MB of the .log file. Default is 200 MB.
4848
5051
      The database will be closed and opened (just like using CHECKPOINT) if
4849
5052
      the .log file gets over this limit, and so the .log file will shrink. 0
4850
5053
      means no limit.</p><p>See also: <a href="#checkpoint-section" title="CHECKPOINT">CHECKPOINT</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="set_password-section"></a>SET PASSWORD</h3></div></div><div></div></div><pre class="programlisting">SET PASSWORD &lt;password&gt;;</pre><p>Changes the password of the currently connected user. Password
4855
5058
      'wrong' order) the checking can be switched off.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Note that when referential integrity is switched back on, no
4856
5059
        check is made that the changes to the data are consistent with the
4857
5060
        existing referential integrity constraints. You can verify consistency
4858
 
        using SQL queries and take appropriate actions.</p></div><p>Only an administrator may do this.</p><p>See also: <a href="#create_table-section" title="CREATE TABLE">CREATE TABLE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1201E"></a>SET SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">SET SCHEMA &lt;schemaname&gt;;</pre><p>Sets the current JDBC session's schema. The sole purpose for the
 
5061
        using SQL queries and take appropriate actions.</p></div><p>Only an administrator may do this.</p><p>See also: <a href="#create_table-section" title="CREATE TABLE">CREATE TABLE</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="set_schema-section"></a>SET SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></h3></div></div><div></div></div><pre class="programlisting">SET SCHEMA &lt;schemaname&gt;;</pre><p>Sets the current JDBC session's schema. The sole purpose for the
4859
5062
      session schema is to provide a default schema name for schema objects
4860
5063
      that do not have the schema name specified explicitly in the SQL
4861
5064
      command, or by association with another object of known schema. For
4871
5074
      file is used for storage of the data. The optional DESC qualifier
4872
5075
      results in the text file indexed from the end and opened as readonly.
4873
5076
      The &lt;file and options&gt; argument is a double quoted string that
4874
 
      consists of:</p><pre class="programlisting">    &lt;file and options&gt;::= &lt;doublequote&gt; &lt;filepath&gt; [&lt;semicolon&gt; &lt;option&gt;...] &lt;doublequote&gt;</pre><p>Example:</p><div class="informalexample"><pre class="programlisting">    SET TABLE mytable SOURCE "myfile;fs=|;vs=.;lvs=~"</pre></div><div class="variablelist"><p class="title"><b>Supported Properties</b></p><dl><dt><span class="term">quoted = { true | false }</span></dt><dd><p>default is true. If false, treats double quotes as normal
 
5077
      consists of:</p><pre class="programlisting">    &lt;file and options&gt;::= &lt;doublequote&gt; &lt;filepath&gt;
 
5078
        [&lt;semicolon&gt; &lt;option&gt;...] &lt;doublequote&gt;</pre><p>Example:</p><div class="informalexample"><pre class="programlisting">    SET TABLE mytable SOURCE "myfile;fs=|;vs=.;lvs=~"</pre></div><div class="variablelist"><p class="title"><b>Supported Properties</b></p><dl><dt><span class="term">quoted = { true | false }</span></dt><dd><p>default is true. If false, treats double quotes as normal
4875
5079
            characters</p></dd><dt><span class="term">all_quoted = { true | false }</span></dt><dd><p>default is false. If true, adds double quotes around all
4876
5080
            fields.</p></dd><dt><span class="term">encoding = &lt;encoding name&gt;</span></dt><dd><p>character encoding for text and character fields, for
4877
5081
            example, encoding=UTF-8</p></dd><dt><span class="term">ignore_first = { true | false }</span></dt><dd><p>default is false. If true ignores the first line of the
4910
5114
            leaving the other part to be performed automatically at the next
4911
5115
            startup.</p><p>This command produces a full script of the database which
4912
5116
            can be edited for special purposes prior to the next
4913
 
            startup.</p></dd></dl></div><p>Only an administrator may use the SHUTDOWN command.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="update-section"></a>UPDATE</h3></div></div><div></div></div><pre class="programlisting">UPDATE table SET column = Expression [, ...] [WHERE Expression];</pre><p>Modifies data of a table in the database.</p><p>See also: <a href="#select-section" title="SELECT">SELECT<sup>[<a href="#ftn.posthyper">1</a>]</sup></a>, <a href="#insert-section" title="INSERT">INSERT</a>, <a href="#delete-section" title="DELETE">DELETE</a>.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="datatypes-section"></a>Data Types</h2></div></div><div></div></div><div class="table"><a name="N12142"></a><p class="title"><b>Table&nbsp;9.1.&nbsp;Data Types. The types on the same line are equivalent.</b></p><table summary="Data Types. The types on the same line are equivalent." width="100%" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Name</th><th align="left">Range</th><th align="left">Java Type</th></tr></thead><tbody><tr><td align="left">INTEGER | INT</td><td align="left">as Java type</td><td align="left"><tt class="literal">int</tt> |
 
5117
            startup.</p></dd></dl></div><p>Only an administrator may use the SHUTDOWN command.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="update-section"></a>UPDATE</h3></div></div><div></div></div><pre class="programlisting">UPDATE table SET column = Expression [, ...] [WHERE Expression];</pre><p>Modifies data of a table in the database.</p><p>See also: <a href="#select-section" title="SELECT">SELECT<sup>[<a href="#ftn.posthyper">1</a>]</sup></a>, <a href="#insert-section" title="INSERT">INSERT</a>, <a href="#delete-section" title="DELETE">DELETE</a>.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="schemanaming-section"></a>Schema object naming</h2></div></div><div></div></div><p><span class="emphasis"><em>Schema</em></span> objects are database objects that are
 
5118
    always scoped to a specific schema. Each schema has a namespace. There may
 
5119
    be multiple schema objects of the same name, each in the namespace of a
 
5120
    different schema. A particular schema object may nearly always be uniquely
 
5121
    identified using the notation <tt class="literal">schemaname.objectname</tt>.
 
5122
    All HSQLDB database objects are schema objects, other than the
 
5123
    following.</p><table summary="Simple list" border="0" class="simplelist"><tr><td>
 
5124
        <p>Users</p>
 
5125
      </td></tr><tr><td>
 
5126
        <p>Roles</p>
 
5127
      </td></tr><tr><td>
 
5128
        <p>Store Procedure Java Classes</p>
 
5129
      </td></tr><tr><td>
 
5130
        <p>HSQL Aliases</p>
 
5131
      </td></tr></table><p>Our current Java-class-based Triggers are not fully schema
 
5132
    objects. However, we are in the process of implementing SQL-conformant
 
5133
    triggers which will encompass our Java-class-based triggers. When this
 
5134
    work is completed, HSQLDB triggers will be schema objects.</p><p>Sequences are schema objects with creation and removal permission
 
5135
    governed by schema authorization (as described hereafter), but GRANT
 
5136
    and REVOKE command do not work yet for sequences.
 
5137
    In a future version of HSQLDB, sequence GRANTs and REVOKEs will work 
 
5138
    similarly to the current GRANT and REVOKE commands for table access.
 
5139
    </p><p>Most of the time, you do not need to specify the schema for the
 
5140
    desired schema object, because the implicit schema is usually the only one
 
5141
    that can be used. For example, when creating an index, the target schema
 
5142
    will default to that of the table which is the target of the index. Named
 
5143
    constraints are an extreme example of this. There is never a need to
 
5144
    specify a schema name for a constraint, since constraint names are only
 
5145
    specified in a CREATE or ALTER TABLE command, and the schema must be that
 
5146
    of the target table. If the implicit schema is not determined by a related
 
5147
    object, then the default comes from your JDBC session's current schema
 
5148
    setting. The session schema value will be your login user's
 
5149
    <span class="emphasis"><em>initial schema</em></span>, or whatever you last set it to with
 
5150
    <a href="#set_schema-section" title="SET SCHEMA">SET SCHEMA<sup>[<a href="#ftn.posthyper">1</a>]</sup></a> in your
 
5151
    <span class="emphasis"><em>current</em></span> JDBC session with the SET SCHEMA command.
 
5152
    (Your initial schema is "PUBLIC" unless changed with the <a href="#alter_user-section" title="ALTER USER"> ALTER USER SET INITIAL SCHEMA</a> or the
 
5153
    <a href="#set_initialschema-section" title="SET INITIAL SCHEMA ">SET INITIAL SCHEMA <sup>[<a href="#ftn.posthyper">1</a>]</sup></a> command).</p><p>In addition to namespace scoping, there are permission aspects to
 
5154
    the schema of a database object. The <span class="emphasis"><em>authorization</em></span> of
 
5155
    a schema is a role or user that is basically the
 
5156
    <span class="emphasis"><em>owner</em></span> of the schema. Only a user with the DBA role
 
5157
    (an admin user) or the owner of a schema may create objects, or modify the
 
5158
    DDL of objects, in the namespace of that schema. In this way, a schema
 
5159
    authorization is said to "own" the objects of that schema. A schema
 
5160
    authorization/owner can be a role or a user (even a role with no members).
 
5161
    The two schemas automatically created when a database is initialized are
 
5162
    both owned by the role <span class="emphasis"><em>DBA</em></span>.</p><p>An important implication to database objects being
 
5163
    <span class="emphasis"><em>owned</em></span> by the schema owner is, if a non-DBA database
 
5164
    user is to have permission to create any database object, they must have
 
5165
    ownership of a schema. To allow a user to create (or modify DDL of)
 
5166
    objects in their own personal schema, you would create a new schema with
 
5167
    that user as the authorization. To allow a non-DBA user to share create
 
5168
    and DDL privileges in some schema, you would create this schema with
 
5169
    a role as the authorization, then GRANT this role to all of the desired
 
5170
    users.</p><p>The INFORMATION_SCHEMA is a system defined schema that contains
 
5171
    the system tables for the database. This schema is read-only. When a
 
5172
    database is created, a shema named PUBLIC is automatically created as the
 
5173
    default schma. This schema has the authorization DBA. You can change the
 
5174
    name of this schema. If all non-system schemas are dropped from a
 
5175
    database, an empty PUBLIC schema is created again. So each database always
 
5176
    has at least one non-system schema.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="datatypes-section"></a>Data Types</h2></div></div><div></div></div><div class="table"><a name="N12272"></a><p class="title"><b>Table&nbsp;9.1.&nbsp;Data Types. The types on the same line are equivalent.</b></p><table summary="Data Types. The types on the same line are equivalent." width="100%" border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Name</th><th align="left">Range</th><th align="left">Java Type</th></tr></thead><tbody><tr><td align="left">INTEGER | INT</td><td align="left">as Java type</td><td align="left"><tt class="literal">int</tt> |
4914
5177
            <tt class="classname">java.lang.Integer</tt></td></tr><tr><td align="left">DOUBLE [PRECISION] | FLOAT</td><td align="left">as Java type</td><td align="left"><tt class="literal">double</tt> |
4915
5178
            <tt class="classname">java.lang.Double</tt></td></tr><tr><td align="left">VARCHAR</td><td align="left">as Integer.MAXVALUE</td><td align="left"><tt class="classname">java.lang.String</tt></td></tr><tr><td align="left">VARCHAR_IGNORECASE</td><td align="left">as Integer.MAXVALUE</td><td align="left"><tt class="classname">java.lang.String</tt></td></tr><tr><td align="left">CHAR | CHARACTER</td><td align="left">as Integer.MAXVALUE</td><td align="left"><tt class="classname">java.lang.String</tt></td></tr><tr><td align="left">LONGVARCHAR</td><td align="left">as Integer.MAXVALUE</td><td align="left"><tt class="classname">java.lang.String</tt></td></tr><tr><td align="left">DATE</td><td align="left">as Java type</td><td align="left"><tt class="classname">java.sql.Date</tt></td></tr><tr><td align="left">TIME</td><td align="left">as Java type</td><td align="left"><tt class="classname">java.sql.Time</tt></td></tr><tr><td align="left">TIMESTAMP | DATETIME</td><td align="left">as Java type</td><td align="left"><tt class="classname">java.sql.Timestamp</tt></td></tr><tr><td align="left">DECIMAL</td><td align="left">No limit</td><td align="left"><tt class="classname">java.math.BigDecimal</tt></td></tr><tr><td align="left">NUMERIC</td><td align="left">No limit</td><td align="left"><tt class="classname">java.math.BigDecimal</tt></td></tr><tr><td align="left">BOOLEAN | BIT</td><td align="left">as Java type</td><td align="left"><tt class="literal">boolean</tt> |
4916
5179
            <tt class="classname">java.lang.Boolean</tt></td></tr><tr><td align="left">TINYINT</td><td align="left">as Java type</td><td align="left"><tt class="literal">byte</tt> |
4949
5212
    comparisons.</p><p>Columns of the type OTHER or OBJECT contain the serialized form of a
4950
5213
    Java Object in binary format. To insert or update such columns, a binary
4951
5214
    format string (see below under Expression) should be used. Using
4952
 
    PreparedStatements with JDBC automates this transformation.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12234"></a>SQL Comments</h2></div></div><div></div></div><table summary="Simple list" border="0" class="simplelist"><tr><td>
 
5215
    PreparedStatements with JDBC automates this transformation.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12364"></a>SQL Comments</h2></div></div><div></div></div><table summary="Simple list" border="0" class="simplelist"><tr><td>
4953
5216
        <tt class="literal">-- SQL style line comment</tt>
4954
5217
      </td></tr><tr><td>
4955
5218
        <tt class="literal">// Java style line comment</tt>
4956
5219
      </td></tr><tr><td>
4957
5220
        <tt class="literal">/* C style line comment */</tt>
4958
 
      </td></tr></table><p>All these types of comments are ignored by the database.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="stored-section"></a>Stored Procedures / Functions</h2></div></div><div></div></div><p>Stored procedures are Java functions that are called directly from
 
5221
      </td></tr></table><p>All these types of comments are ignored by the database.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="stored-section"></a>Stored Procedures / Functions</h2></div></div><div></div></div><p>Stored procedures are static Java functions that are called 
 
5222
    directly from
4959
5223
    the SQL language or using an alias. Calling Java functions (directly or
4960
5224
    using the alias) requires that the Java class can be reached by the
4961
5225
    database (server). The syntax is:</p><pre class="programlisting">    "java.lang.Math.sqrt"(2.0)</pre><p>This means the package must be provided, and the name must be
4967
5231
    If you want to use Java library methods, it is recommended that you create
4968
5232
    your own class with static methods that act as wrappers around the Java
4969
5233
    library methods. This will allow you to control which method signature is
4970
 
    used to call each Java library method.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12265"></a>Built-in Functions and Stored Procedures</h2></div></div><div></div></div><div class="variablelist"><p class="title"><b>Numerical built-in Functions / Stored Procedures</b></p><dl><dt><span class="term">ABS(d)</span></dt><dd><p>returns the absolute value of a double value</p></dd><dt><span class="term">ACOS(d)</span></dt><dd><p>returns the arc cosine of an angle</p></dd><dt><span class="term">ASIN(d)</span></dt><dd><p>returns the arc sine of an angle</p></dd><dt><span class="term">ATAN(d)</span></dt><dd><p>returns the arc tangent of an angle</p></dd><dt><span class="term">ATAN2(a,b)</span></dt><dd><p>returns the tangent of a/b</p></dd><dt><span class="term">BITAND(a,b)</span></dt><dd><p>return a &amp; b</p></dd><dt><span class="term">BITOR(a,b)</span></dt><dd><p>returns a | b</p></dd><dt><span class="term">CEILING(d)</span></dt><dd><p>returns the smallest integer that is not less than d</p></dd><dt><span class="term">COS(d)</span></dt><dd><p>returns the cosine of an angle</p></dd><dt><span class="term">COT(d)</span></dt><dd><p>returns the cotangent of an angle</p></dd><dt><span class="term">DEGREES(d)</span></dt><dd><p>converts radians to degrees</p></dd><dt><span class="term">EXP(d)</span></dt><dd><p>returns e (2.718...) raised to the power of d</p></dd><dt><span class="term">FLOOR(d)</span></dt><dd><p>returns the largest integer that is not greater than d</p></dd><dt><span class="term">LOG(d)</span></dt><dd><p>returns the natural logarithm (base e)</p></dd><dt><span class="term">LOG10(d)</span></dt><dd><p>returns the logarithm (base 10)</p></dd><dt><span class="term">MOD(a,b)</span></dt><dd><p>returns a modulo b</p></dd><dt><span class="term">PI()</span></dt><dd><p>returns pi (3.1415...)</p></dd><dt><span class="term">POWER(a,b)</span></dt><dd><p>returns a raised to the power of b</p></dd><dt><span class="term">RADIANS(d)</span></dt><dd><p>converts degrees to radians</p></dd><dt><span class="term">RAND()</span></dt><dd><p>returns a random number x bigger or equal to 0.0 and smaller
 
5234
    used to call each Java library method.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12395"></a>Built-in Functions and Stored Procedures</h2></div></div><div></div></div><div class="variablelist"><p class="title"><b>Numerical built-in Functions / Stored Procedures</b></p><dl><dt><span class="term">ABS(d)</span></dt><dd><p>returns the absolute value of a double value</p></dd><dt><span class="term">ACOS(d)</span></dt><dd><p>returns the arc cosine of an angle</p></dd><dt><span class="term">ASIN(d)</span></dt><dd><p>returns the arc sine of an angle</p></dd><dt><span class="term">ATAN(d)</span></dt><dd><p>returns the arc tangent of an angle</p></dd><dt><span class="term">ATAN2(a,b)</span></dt><dd><p>returns the tangent of a/b</p></dd><dt><span class="term">BITAND(a,b)</span></dt><dd><p>return a &amp; b</p></dd><dt><span class="term">BITOR(a,b)</span></dt><dd><p>returns a | b</p></dd><dt><span class="term">CEILING(d)</span></dt><dd><p>returns the smallest integer that is not less than d</p></dd><dt><span class="term">COS(d)</span></dt><dd><p>returns the cosine of an angle</p></dd><dt><span class="term">COT(d)</span></dt><dd><p>returns the cotangent of an angle</p></dd><dt><span class="term">DEGREES(d)</span></dt><dd><p>converts radians to degrees</p></dd><dt><span class="term">EXP(d)</span></dt><dd><p>returns e (2.718...) raised to the power of d</p></dd><dt><span class="term">FLOOR(d)</span></dt><dd><p>returns the largest integer that is not greater than d</p></dd><dt><span class="term">LOG(d)</span></dt><dd><p>returns the natural logarithm (base e)</p></dd><dt><span class="term">LOG10(d)</span></dt><dd><p>returns the logarithm (base 10)</p></dd><dt><span class="term">MOD(a,b)</span></dt><dd><p>returns a modulo b</p></dd><dt><span class="term">PI()</span></dt><dd><p>returns pi (3.1415...)</p></dd><dt><span class="term">POWER(a,b)</span></dt><dd><p>returns a raised to the power of b</p></dd><dt><span class="term">RADIANS(d)</span></dt><dd><p>converts degrees to radians</p></dd><dt><span class="term">RAND()</span></dt><dd><p>returns a random number x bigger or equal to 0.0 and smaller
4971
5235
          than 1.0</p></dd><dt><span class="term">ROUND(a,b)</span></dt><dd><p>rounds a to b digits after the decimal point</p></dd><dt><span class="term">ROUNDMAGIC(d)</span></dt><dd><p>solves rounding problems such as 3.11-3.1-0.01</p></dd><dt><span class="term">SIGN(d)</span></dt><dd><p>returns -1 if d is smaller than 0, 0 if d==0 and 1 if d is
4972
5236
          bigger than 0</p></dd><dt><span class="term">SIN(d)</span></dt><dd><p>returns the sine of an angle</p></dd><dt><span class="term">SQRT(d)</span></dt><dd><p>returns the square root</p></dd><dt><span class="term">TAN(A)</span></dt><dd><p>returns the trigonometric tangent of an angle</p></dd><dt><span class="term">TRUNCATE(a,b)</span></dt><dd><p>truncates a to b digits after the decimal point</p></dd></dl></div><div class="variablelist"><p class="title"><b>String built-in Functions / Stored Procedures</b></p><dl><dt><span class="term">ASCII(s)</span></dt><dd><p>returns the ASCII code of the leftmost character of s</p></dd><dt><span class="term">BIT_LENGTH(str)<sup>[<a href="#ftn.posthyper">1</a>]</sup></span></dt><dd><p>returns the length of the string in bits</p></dd><dt><span class="term">CHAR(c)</span></dt><dd><p>returns a character that has the ASCII code c</p></dd><dt><span class="term">CHAR_LENGTH(str)<sup>[<a href="#ftn.posthyper">1</a>]</sup></span></dt><dd><p>returns the length of the string in characters</p></dd><dt><span class="term">CONCAT(str1,str2)</span></dt><dd><p>returns str1 + str2</p></dd><dt><span class="term">DIFFERENCE(s1,s2)</span></dt><dd><p>returns the difference between the sound of s1 and s2</p></dd><dt><span class="term">HEXTORAW(s1)<sup>[<a href="#ftn.posthyper">1</a>]</sup></span></dt><dd><p>returns translated string</p></dd><dt><span class="term">INSERT(s,start,len,s2)</span></dt><dd><p>returns a string where len number of characters beginning at
4973
5237
          start has been replaced by s2</p></dd><dt><span class="term">LCASE(s)</span></dt><dd><p>converts s to lower case</p></dd><dt><span class="term">LEFT(s,count)</span></dt><dd><p>returns the leftmost count of characters of s) - requires
5048
5312
          character, including space. In a quoted identifier use "" (two
5049
5313
          doublequotes) to create a " (one doublequote). With quoted
5050
5314
          identifiers it is possible to create mixed-case table and column
5051
 
          names. Example:</p><div class="informalexample"><pre class="programlisting">    CREATE TABLE "Address" ("Nr" INTEGER,"Name" VARCHAR); SELECT "Nr", "Name" FROM "Address";</pre></div><p>The equivalent quoted identifier can be used for an unquoted
 
5315
          names. Example:</p><div class="informalexample"><pre class="programlisting">    CREATE TABLE "Address" ("Nr" INTEGER,"Name" VARCHAR);
 
5316
    SELECT "Nr", "Name" FROM "Address";</pre></div><p>The equivalent quoted identifier can be used for an unquoted
5052
5317
          identifer by converting the identifier to all uppercase and quoting
5053
5318
          it. For example, if a table name is defined as Address2 (unquoted),
5054
5319
          it can be referred to by its quoted form, "ADDRESS2", as well as
5096
5361
    (semicolon) must be used at the end of each command to ensure data
5097
5362
    integrity, despite the fact that the engine may understand the end of
5098
5363
    commands and not return an error when a semicolon is not used.</p></div><div class="footnotes"><br><hr align="left" width="100"><div class="footnote"><p><sup>[<a href="#posthyper" name="ftn.posthyper">1</a>] </sup>These features were added by HSQL Development Group since
5099
 
          April 2001</p></div></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="building-appendix"></a>Appendix&nbsp;A.&nbsp;Building HSQLDB</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/05/26 23:22:06 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1256A">Purpose</a></span></dt><dt><span class="section"><a href="#N12573">Building with Ant</a></span></dt><dd><dl><dt><span class="section"><a href="#N1257A">Obtaining Ant</a></span></dt><dt><span class="section"><a href="#N12592">Building Hsqldb with Ant</a></span></dt></dl></dd><dt><span class="section"><a href="#N12641">Building with DOS Batch Files</a></span></dt><dt><span class="section"><a href="#N1265A">Hsqldb CodeSwitcher</a></span></dt><dt><span class="section"><a href="#N12686">Building documentation</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1256A"></a>Purpose</h2></div></div><div></div></div><p>From 1.8.0, the supplied <tt class="filename">hsqldb.jar</tt> file is
 
5364
          April 2001</p></div></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="building-appendix"></a>Appendix&nbsp;A.&nbsp;Building HSQLDB</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/05/26 23:22:06 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N1269A">Purpose</a></span></dt><dt><span class="section"><a href="#N126A3">Building with Ant</a></span></dt><dd><dl><dt><span class="section"><a href="#N126AA">Obtaining Ant</a></span></dt><dt><span class="section"><a href="#N126C2">Building Hsqldb with Ant</a></span></dt></dl></dd><dt><span class="section"><a href="#N12771">Building with DOS Batch Files</a></span></dt><dt><span class="section"><a href="#N1278A">Hsqldb CodeSwitcher</a></span></dt><dt><span class="section"><a href="#N127B6">Building documentation</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1269A"></a>Purpose</h2></div></div><div></div></div><p>From 1.8.0, the supplied <tt class="filename">hsqldb.jar</tt> file is
5100
5365
    built with Java 1.5. If you want to run the engine under JDK1.3 or
5101
 
    earlier, you should rebuild the jar with Ant.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12573"></a>Building with Ant, from the Apache Jakarta Project</h2></div></div><div></div></div><p>Ant (Another Neat Tool) is used for building hsqldb. The version
 
5366
    earlier, you should rebuild the jar with Ant.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N126A3"></a>Building with Ant, from the Apache Jakarta Project</h2></div></div><div></div></div><p>Ant (Another Neat Tool) is used for building hsqldb. The version
5102
5367
    currently used to test the build script is 1.6.1 but versions since 1.5.1
5103
 
    should also be compatible.</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1257A"></a>Obtaining Ant</h3></div></div><div></div></div><p>Ant is a part of the Jakarta/Apache Project.</p><div class="itemizedlist"><ul type="disc"><li><p>
 
5368
    should also be compatible.</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N126AA"></a>Obtaining Ant</h3></div></div><div></div></div><p>Ant is a part of the Jakarta/Apache Project.</p><div class="itemizedlist"><ul type="disc"><li><p>
5104
5369
            <a href="http://ant.apache.org" target="_top">Home of the Apache Ant
5105
5370
            project</a>
5106
5371
          </p></li><li><p>The <a href="http://ant.apache.org/manual/install.html#installing" target="_top">
5107
5372
          Installing Ant</a> page of the <a href="http://ant.apache.org/manual" target="_top">Ant Manual </a>. Follow the
5108
 
          directions for your platform.</p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N12592"></a>Building Hsqldb with Ant</h3></div></div><div></div></div><p>Once you have unpacked the zip package for hsqldb, under the
 
5373
          directions for your platform.</p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N126C2"></a>Building Hsqldb with Ant</h3></div></div><div></div></div><p>Once you have unpacked the zip package for hsqldb, under the
5109
5374
      <tt class="filename">/hsqldb</tt> folder, in <tt class="filename">/build</tt>
5110
5375
      there is a <tt class="filename">build.xml</tt> file that builds the
5111
5376
      <tt class="filename">hsqldb.jar</tt> with Ant (Ant must be already
5138
5403
      numbers, which can be extremely useful for debugging.</p><p>The preferred method of rebuilding the jar is with Ant. After
5139
5404
      installing Ant on your system use the following command from the
5140
5405
      <tt class="filename">/build</tt> directory:</p><div class="informalexample"><pre class="screen">ant explainjars</pre></div><p>The command displays a list of different options for building
5141
 
      different sizes of the HSQLDB Jar. The default is built using:</p><div class="example"><a name="N12633"></a><p class="title"><b>Example&nbsp;A.1.&nbsp;Buiding the standard Hsqldb jar file with Ant</b></p><pre class="screen">ant hsqldb</pre></div><p>The Ant method always builds a jar with the JDK that is used by
 
5406
      different sizes of the HSQLDB Jar. The default is built using:</p><div class="example"><a name="N12763"></a><p class="title"><b>Example&nbsp;A.1.&nbsp;Buiding the standard Hsqldb jar file with Ant</b></p><pre class="screen">ant hsqldb</pre></div><p>The Ant method always builds a jar with the JDK that is used by
5142
5407
      Ant and specified in its JAVA_HOME environment variable. Building with
5143
5408
      JDK 1.4.x or 1.5.x will result in a jar that is not backward compatible.
5144
5409
      </p><p>From version 1.7.2, use of JDK 1.1.x is not recommended for
5151
5416
      the jar.<div class="informalexample"><pre class="screen">ant switchtojdk12
5152
5417
ant switchtojava1target
5153
5418
ant hsqldb
5154
 
</pre></div></p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12641"></a>Building with DOS Batch Files</h2></div></div><div></div></div><p>UNIX users must use Ant to build hsqldb.</p><p>For DOS/Windows users, a set of MSDOS batch files is provided as an
 
5419
</pre></div></p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12771"></a>Building with DOS Batch Files</h2></div></div><div></div></div><p>UNIX users must use Ant to build hsqldb.</p><p>For DOS/Windows users, a set of MSDOS batch files is provided as an
5155
5420
    example. These files produce only the default jar size. The path and
5156
5421
    classpath variables for the JDK should of course be set before running any
5157
5422
    of the batch files. These files are not currently maintained and will
5161
5426
    <tt class="filename">switchToJDK12.bat</tt> to adapt the source files to the
5162
5427
    target JDK before running the appropriate
5163
5428
    <tt class="filename">buildJDK11.bat</tt> or <tt class="filename">buildJDK12.bat</tt>
5164
 
    JDK and JRE versions.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1265A"></a>Hsqldb CodeSwitcher</h2></div></div><div></div></div><p>CodeSwitcher is a tool to manage different version of Java source
 
5429
    JDK and JRE versions.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N1278A"></a>Hsqldb CodeSwitcher</h2></div></div><div></div></div><p>CodeSwitcher is a tool to manage different version of Java source
5165
5430
    code. It allows to compile HSQLDB for different JDKs. It is something like
5166
5431
    a precompiler in C but it works directly on the source code and does not
5167
5432
    create intermediate output or extra files.</p><p>CodeSwitcher is used internally in HSQLDB build scripts. You do not
5168
5433
    have to use it separately to compile HSQLDB.</p><p>CodeSwitcher reads the source code of a file, removes comments where
5169
5434
    appropriate and comments out the blocks that are not used for a particular
5170
5435
    version of the file. This operation is done for all files of a defined
5171
 
    directory, and all subdirectories.</p><div class="example"><a name="N12663"></a><p class="title"><b>Example&nbsp;A.2.&nbsp;Example source code before CodeSwitcher is run</b></p><pre class="programlisting">
 
5436
    directory, and all subdirectories.</p><div class="example"><a name="N12793"></a><p class="title"><b>Example&nbsp;A.2.&nbsp;Example source code before CodeSwitcher is run</b></p><pre class="programlisting">
5172
5437
        ...
5173
5438
 
5174
5439
    //#ifdef JAVA2
5185
5450
 
5186
5451
    //#endif
5187
5452
 
5188
 
        ...</pre></div><p>The next step is to run CodeSwitcher.</p><div class="example"><a name="N1266B"></a><p class="title"><b>Example&nbsp;A.3.&nbsp;CodeSwitcher command line invocation</b></p><pre class="screen">
 
5453
        ...</pre></div><p>The next step is to run CodeSwitcher.</p><div class="example"><a name="N1279B"></a><p class="title"><b>Example&nbsp;A.3.&nbsp;CodeSwitcher command line invocation</b></p><pre class="screen">
5189
5454
    java org.hsqldb.util.CodeSwitcher . -JAVA2</pre></div><p>The '.' means the program works on the current directory (all
5190
5455
    subdirectories are processed recursively). <tt class="literal">-JAVA2</tt> means
5191
 
    the code labelled with JAVA2 must be switched off.</p><div class="example"><a name="N12677"></a><p class="title"><b>Example&nbsp;A.4.&nbsp;Source code after CodeSwitcher processing</b></p><pre class="programlisting">
 
5456
    the code labelled with JAVA2 must be switched off.</p><div class="example"><a name="N127A7"></a><p class="title"><b>Example&nbsp;A.4.&nbsp;Source code after CodeSwitcher processing</b></p><pre class="programlisting">
5192
5457
        ...
5193
5458
 
5194
5459
    //#ifdef JAVA2
5208
5473
        ...</pre></div><p>For detailed information on the command line options run
5209
5474
    <tt class="classname">java org.hsqldb.util.CodeSwitcher</tt>. Usage examples
5210
5475
    can be found in the switchtojdk1*.bat files in the
5211
 
    <tt class="filename">/build</tt> directory.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12686"></a>Building documentation</h2></div></div><div></div></div><p>To build the User Guide in HTML format, you must have the Docbook
 
5476
    <tt class="filename">/build</tt> directory.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N127B6"></a>Building documentation</h2></div></div><div></div></div><p>To build the User Guide in HTML format, you must have the Docbook
5212
5477
    stylesheets installed locally. The Docbook stylesheets are available on
5213
5478
    the Internet. On Linux, just install the
5214
5479
    <tt class="literal">docbook-xsl-stylesheets</tt> rpm. Then add an entry to
5215
5480
    <tt class="filename">build.properties</tt> in your build directory with
5216
5481
    contents like <div class="informalexample"><pre class="screen">docbook.xsl.home: /usr/share/sgml/docbook/docbook-xsl-stylesheets</pre></div> Where you specify your local path to the base
5217
 
    directory of your Docbook stylesheet installation. Build like <div class="example"><a name="N12698"></a><p class="title"><b>Example&nbsp;A.5.&nbsp;Building HTML User Guides</b></p><pre class="screen">ant docbooks-html
 
5482
    directory of your Docbook stylesheet installation. Build like <div class="example"><a name="N127C8"></a><p class="title"><b>Example&nbsp;A.5.&nbsp;Building HTML User Guides</b></p><pre class="screen">ant docbooks-html
5218
5483
ant docbooks-chunk</pre></div></p><p>To build the User Guide in PDF format, you must also have the Java
5219
5484
    FOP system installed locally. FOP is available for free download on the
5220
5485
    Internet. Add an entry to <tt class="filename">build.properties</tt> in your
5221
5486
    build directory with contents like <div class="informalexample"><pre class="screen">fop.home /usr/local/fop-0.20.5</pre></div> Where you specify your local path to the base
5222
 
    directory of your FOP installation. <div class="example"><a name="N126A9"></a><p class="title"><b>Example&nbsp;A.6.&nbsp;Building User Guides in all formats</b></p><pre class="screen">ant docbook</pre></div> Don't pay too much attention to error messages by FOP,
 
5487
    directory of your FOP installation. <div class="example"><a name="N127D9"></a><p class="title"><b>Example&nbsp;A.6.&nbsp;Building User Guides in all formats</b></p><pre class="screen">ant docbook</pre></div> Don't pay too much attention to error messages by FOP,
5223
5488
    because they are really warnings, but do check the output. If there are
5224
5489
    problems with the PDF output, try using a newer version of FOP.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>By default, your docs will fail to build if you do not have
5225
5490
      Internet connectivity. This is because our primary Docbook source file
5237
5502
            There is a copy of <tt class="filename">Testdb.java</tt> in the
5238
5503
            directory <tt class="filename">src/org/hsqldb/sample</tt> of your
5239
5504
            HSQLDB distribution.
5240
 
        </p><div class="example"><a name="N126DA"></a><p class="title"><b>Example&nbsp;B.1.&nbsp;JDBC Client source code example</b></p><pre class="programlisting">/* Copyright (c) 2001-2005, The HSQL Development Group
 
5505
        </p><div class="example"><a name="N1280A"></a><p class="title"><b>Example&nbsp;B.1.&nbsp;JDBC Client source code example</b></p><pre class="programlisting">/* Copyright (c) 2001-2005, The HSQL Development Group
5241
5506
 * All rights reserved.
5242
5507
 *
5243
5508
 * Redistribution and use in source and binary forms, with or without
5440
5705
    }    // main()
5441
5706
}    // class Testdb
5442
5707
 
5443
 
</pre></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N126E1"></a>Appendix&nbsp;C.&nbsp;Hsqldb Database Files and Recovery</h2></div><div><div class="legalnotice"><p>
 
5708
</pre></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12811"></a>Appendix&nbsp;C.&nbsp;Hsqldb Database Files and Recovery</h2></div><div><div class="legalnotice"><p>
5444
5709
        This text is based on HypersonicSQL documentation, updated to reflect 
5445
5710
        the latest version 1.8.0 of HSQLDB.
5446
 
    </p></div></div><div><p class="pubdate">$Date: 2005/07/01 17:06:32 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N126F8"></a></span></dt><dt><span class="section"><a href="#N12728">States</a></span></dt><dd><dl><dt><span class="section"><a href="#N1272B"></a></span></dt><dt><span class="section"><a href="#N1275A"></a></span></dt><dt><span class="section"><a href="#N12789"></a></span></dt></dl></dd><dt><span class="section"><a href="#N127BB">Procedures</a></span></dt><dd><dl><dt><span class="section"><a href="#N127C0">Clean Shutdown</a></span></dt><dt><span class="section"><a href="#N1281A">Startup</a></span></dt><dt><span class="section"><a href="#N1286C">Repair</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div></div><div></div></div><p>
 
5711
    </p></div></div><div><p class="pubdate">$Date: 2005/07/01 17:06:32 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N12828"></a></span></dt><dt><span class="section"><a href="#N12858">States</a></span></dt><dd><dl><dt><span class="section"><a href="#N1285B"></a></span></dt><dt><span class="section"><a href="#N1288A"></a></span></dt><dt><span class="section"><a href="#N128B9"></a></span></dt></dl></dd><dt><span class="section"><a href="#N128EB">Procedures</a></span></dt><dd><dl><dt><span class="section"><a href="#N128F0">Clean Shutdown</a></span></dt><dt><span class="section"><a href="#N1294A">Startup</a></span></dt><dt><span class="section"><a href="#N1299C">Repair</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div></div><div></div></div><p>
5447
5712
        The Standalone and Client/Server modes will in most cases use files to 
5448
5713
        store all data to disk in a persistent and safe way.
5449
5714
        This document describes the meaning of the files, the states and the 
5472
5737
        </p><p>
5473
5738
        In the above list, a checkpoint results from both a CHECKPOINT command 
5474
5739
        and a SHUTDOWN command.
5475
 
        </p></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12728"></a>States</h2></div></div><div></div></div><div class="section" lang="en"><div class="titlepage"><div></div><div></div></div>Database is closed correctly</div><div class="itemizedlist"><p class="title"><b>State after using the command <tt class="literal">SHUTDOWN</tt></b></p><ul type="disc"><li><p>
 
5740
        </p></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12858"></a>States</h2></div></div><div></div></div><div class="section" lang="en"><div class="titlepage"><div></div><div></div></div>Database is closed correctly</div><div class="itemizedlist"><p class="title"><b>State after using the command <tt class="literal">SHUTDOWN</tt></b></p><ul type="disc"><li><p>
5476
5741
            The <tt class="filename">test.data</tt> file is fully updated.
5477
5742
        </p></li><li><p>
5478
5743
            The <tt class="filename">test.backup</tt> contains the compressed 
5519
5784
            re-do all changes since the snanapshot.
5520
5785
            As a result of abnormal termination, this file may be partially 
5521
5786
            corrupt.
5522
 
        </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N127BB"></a>Procedures</h2></div></div><div></div></div><p>
 
5787
        </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N128EB"></a>Procedures</h2></div></div><div></div></div><p>
5523
5788
        The database engine performs the following procedures internally in 
5524
5789
        different circumstances. 
5525
 
    </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N127C0"></a>Clean Shutdown</h3></div></div><div></div></div><div class="procedure"><p class="title"><b>Procedure&nbsp;C.1.&nbsp;Clean Hsqldb database shutdown</b></p><ol type="1"><li><p>
 
5790
    </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N128F0"></a>Clean Shutdown</h3></div></div><div></div></div><div class="procedure"><p class="title"><b>Procedure&nbsp;C.1.&nbsp;Clean Hsqldb database shutdown</b></p><ol type="1"><li><p>
5526
5791
                The <tt class="filename">test.data</tt> file is written completely 
5527
5792
                (all the modified cached table rows are witten out) and closed.
5528
5793
            </p></li><li><p>
5549
5814
                The entry 'modified' in the properties file is set to 'no' 
5550
5815
            </p></li><li><p>
5551
5816
                The file <tt class="filename">test.log</tt> is deleted
5552
 
            </p></li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1281A"></a>Startup</h3></div></div><div></div></div><div class="procedure"><p class="title"><b>Procedure&nbsp;C.2.&nbsp;Database is opened</b></p><ol type="1"><li><p>
 
5817
            </p></li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1294A"></a>Startup</h3></div></div><div></div></div><div class="procedure"><p class="title"><b>Procedure&nbsp;C.2.&nbsp;Database is opened</b></p><ol type="1"><li><p>
5553
5818
                Check if the database files are in use (by checking a special 
5554
5819
                <tt class="filename">test.lck</tt> file).
5555
5820
            </p></li><li><p>
5580
5845
                commands.
5581
5846
            </p></li><li><p>
5582
5847
                Create the empty test.log to append new commands.
5583
 
            </p></li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1286C"></a>Repair</h3></div></div><div></div></div><p>
 
5848
            </p></li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N1299C"></a>Repair</h3></div></div><div></div></div><p>
5584
5849
            The current <tt class="filename">test.data</tt> file is corrupt, but 
5585
5850
            with the old <tt class="filename">test.data</tt> (from the 
5586
5851
            <tt class="filename">test.backup</tt> file and 
5601
5866
                ignored.
5602
5867
            </p></li><li><p>
5603
5868
                Close the database correctly (including a backup).
5604
 
            </p></li></ol></div></div></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N128B2"></a>Appendix&nbsp;D.&nbsp;Running Hsqldb with OpenOffice.org 1.1.x</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Hermann</span> <span class="surname">Kienlein</span></h3><div class="affiliation"><span class="orgname">EDV - Systeme Kienlein<br></span></div><tt class="email">&lt;<a href="mailto:hermann@kienlein.com">hermann@kienlein.com</a>&gt;</tt></div></div><div><div class="legalnotice"><p>
 
5869
            </p></li></ol></div></div></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N129E2"></a>Appendix&nbsp;D.&nbsp;Running Hsqldb with OpenOffice.org 1.1.x</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Hermann</span> <span class="surname">Kienlein</span></h3><div class="affiliation"><span class="orgname">EDV - Systeme Kienlein<br></span></div><tt class="email">&lt;<a href="mailto:hermann@kienlein.com">hermann@kienlein.com</a>&gt;</tt></div></div><div><div class="legalnotice"><p>
5605
5870
            Copyright 2003-2004 Hermann Kienlein.
5606
5871
            Permission is granted to distribute this document without any 
5607
5872
            alteration under the terms of the HSQLDB license.
5608
5873
            Additional permission is granted to the HSQLDB Development Group to 
5609
5874
            distribute this document with or without alterations under the 
5610
5875
            terms of the HSQLDB license.
5611
 
        </p></div></div><div><p class="pubdate">$Date: 2005/06/08 16:02:34 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N128D2">Introduction</a></span></dt><dt><span class="section"><a href="#N128DB">Installing</a></span></dt><dt><span class="section"><a href="#N128E0">Setting up OpenOffice.org</a></span></dt><dd><dl><dt><span class="section"><a href="#N128F2">On Windows</a></span></dt><dt><span class="section"><a href="#N12905">On Linux</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N128D2"></a>Introduction</h2></div></div><div></div></div><p>
 
5876
        </p></div></div><div><p class="pubdate">$Date: 2005/06/08 16:02:34 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N12A02">Introduction</a></span></dt><dt><span class="section"><a href="#N12A0B">Installing</a></span></dt><dt><span class="section"><a href="#N12A10">Setting up OpenOffice.org</a></span></dt><dd><dl><dt><span class="section"><a href="#N12A22">On Windows</a></span></dt><dt><span class="section"><a href="#N12A35">On Linux</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A02"></a>Introduction</h2></div></div><div></div></div><p>
5612
5877
            HSQLDB can now act as a Database with OpenOffice.org.
5613
5878
            This document is written to help you connecting and running HSQLDB 
5614
5879
            out of OpenOffice.org in a simple way.
5622
5887
            HSQLDB is included with OpenOffice.org 2.0 and is used by default.
5623
5888
            Please refer to standard OpenOffice.org 2.0 documentation on how 
5624
5889
            to use HSQLDB with this version.
5625
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N128DB"></a>Installing</h2></div></div><div></div></div><p>
 
5890
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A0B"></a>Installing</h2></div></div><div></div></div><p>
5626
5891
            I assume you have a running OpenOffice.org (OOo) and a
5627
5892
            JavaRuntimeEnvironment.
5628
5893
            So place the hsqldb_*.zip file where you want on your disk 
5629
5894
            and unpack it (I assume you have done this already).
5630
 
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N128E0"></a>Setting up OpenOffice.org</h2></div></div><div></div></div><p>
 
5895
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A10"></a>Setting up OpenOffice.org</h2></div></div><div></div></div><p>
5631
5896
            Start OOo with a text document and go to the Database-Explorer
5632
5897
            (simply by pressing F4).
5633
5898
            In the left frame you see a tree-view with all known databases in
5643
5908
        </p><p>
5644
5909
            As Driver-Class insert <tt class="classname">org.hsqldb.jdbcDriver</tt> 
5645
5910
            and as URL choose the following:
5646
 
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N128F2"></a>On Windows</h3></div></div><div></div></div><p>
 
5911
        </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N12A22"></a>On Windows</h3></div></div><div></div></div><p>
5647
5912
                You can specify a directory where HSQLDB should store the info 
5648
5913
                and data. Something like 
5649
5914
                <tt class="literal">jdbc:hsqldb:file:c:\javasrc\hsqldb-dev\databasename</tt>
5658
5923
            </p><p>
5659
5924
                The first is the directory-path and the databasename is the 
5660
5925
                identifier for the database.
5661
 
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N12905"></a>On Linux</h3></div></div><div></div></div><p>
 
5926
            </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="N12A35"></a>On Linux</h3></div></div><div></div></div><p>
5662
5927
                Choose a path as said for windows like /opt/db/data
5663
5928
            </p><p>
5664
5929
                As username take sa, this is the standard-administrator for 
5699
5964
            Be sure that you exit Quickstarter and all running processes too.
5700
5965
            On next OOo-Start you should have a running Database in 
5701
5966
            OpenOffice.org.
5702
 
        </p></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12925"></a>Appendix&nbsp;E.&nbsp;Hsqldb Test Utility</h2></div><div><p class="pubdate">$Date: 2005/05/27 12:41:50 $</p></div></div><div></div></div><p>The <tt class="literal">org.hsqldb.test</tt> package contains a number of
 
5967
        </p></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12A55"></a>Appendix&nbsp;E.&nbsp;Hsqldb Test Utility</h2></div><div><p class="pubdate">$Date: 2005/05/27 12:41:50 $</p></div></div><div></div></div><p>The <tt class="literal">org.hsqldb.test</tt> package contains a number of
5703
5968
  tests for various functions of the database engine. Among these, the
5704
5969
  <tt class="classname">TestSelf</tt> class performs the tests that are based on
5705
5970
  scripts. To run the tests, you should compile the
5744
6009
      run. The utility will just report the test blocks that have been
5745
6010
      excluded without running them. Once the code has been developed, the
5746
6011
      option can be turned into lowercase to perform the actual test. </p></li></ul></div><p>See the TestSelf*.txt files in the /testrun/hsqldb/ directory for
5747
 
  actual examples.</p></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N1299B"></a>Appendix&nbsp;F.&nbsp;Database Manager</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div><div class="author"><h3 class="author"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/07/25 23:21:10 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N129C4">Brief Introduction</a></span></dt><dt><span class="section"><a href="#N129EE">Auto tree-update</a></span></dt><dt><span class="section"><a href="#N12A05">Automatic Connection</a></span></dt><dt><span class="section"><a href="#N12A13">RC File</a></span></dt><dt><span class="section"><a href="#N12A38">Using the current DatabaseManagers with an older HSQLDB
5748
 
    distribution.</a></span></dt><dt><span class="section"><a href="#N12A6A">DatabaseManagerSwing as an Applet</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N129C4"></a>Brief Introduction</h2></div></div><div></div></div><p>The Database Manager tool is a simple GUI database query tool with a
 
6012
  actual examples.</p></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12ACB"></a>Appendix&nbsp;F.&nbsp;Database Manager</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div><div class="author"><h3 class="author"><span class="firstname">Blaine</span> <span class="surname">Simpson</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/07/25 23:21:10 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N12AF4">Brief Introduction</a></span></dt><dt><span class="section"><a href="#N12B1E">Auto tree-update</a></span></dt><dt><span class="section"><a href="#N12B35">Automatic Connection</a></span></dt><dt><span class="section"><a href="#N12B43">RC File</a></span></dt><dt><span class="section"><a href="#N12B68">Using the current DatabaseManagers with an older HSQLDB
 
6013
    distribution.</a></span></dt><dt><span class="section"><a href="#N12B9A">DatabaseManagerSwing as an Applet</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12AF4"></a>Brief Introduction</h2></div></div><div></div></div><p>The Database Manager tool is a simple GUI database query tool with a
5749
6014
    tree display of the tables. Both AWT and SWING versions of the tool are
5750
6015
    available and work almost identically. The AWT version class name is
5751
6016
    org.hsqldb.util.DatabaseManager; the SWING version,
5777
6042
        <span class="emphasis"><em>before connecting to the database</em></span>.
5778
6043
        You may also want to turn off Auto tree-update, as described in
5779
6044
        the next section.
5780
 
    </div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N129EE"></a>Auto tree-update</h2></div></div><div></div></div><p>By default, the object tree in the left panel is refreshed when
 
6045
    </div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12B1E"></a>Auto tree-update</h2></div></div><div></div></div><p>By default, the object tree in the left panel is refreshed when
5781
6046
    you execute DDL which may update those objects. If you are on a slow
5782
6047
    network or performance-challenged PC, use the <span class="guimenu">view</span> /
5783
6048
    <span class="guimenuitem">Auto-refresh tree</span> menu item to turn it off. You
5786
6051
    tree.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Auto-refresh tree does not automatically show all updates to
5787
6052
      database objects, it only refreshes when you submit DDL which may update
5788
6053
      database objects. (This behavior is a compromise between utility and
5789
 
      performance).</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A05"></a>Automatic Connection</h2></div></div><div></div></div><p>You can use command-line switches to supply connection information.
 
6054
      performance).</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12B35"></a>Automatic Connection</h2></div></div><div></div></div><p>You can use command-line switches to supply connection information.
5790
6055
    If you use these switch(es), then the connection dialog window will be
5791
6056
    skipped and a JDBC connection will be established immediately. Assuming
5792
6057
    that the hsqldb.jar (or an alternative jar) are in your CLASSPATH, this
5796
6061
      command-lines is generally available to other users on the computer. The
5797
6062
      problem is compounded if you use a network connection to obtain your
5798
6063
      command line. The RC File section explains how you can set up automatic
5799
 
      connections without supplying a password on the command line.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A13"></a>RC File</h2></div></div><div></div></div><p>You can skip the connection dialog window securely by putting the
 
6064
      connections without supplying a password on the command line.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12B43"></a>RC File</h2></div></div><div></div></div><p>You can skip the connection dialog window securely by putting the
5800
6065
    connection information into an RC file and then using the
5801
6066
    <tt class="literal">--urlid</tt> switch to DatabaseManager or
5802
6067
    DatabaseManagerSwing. This strategy is great for adding launch menu items
5810
6075
      reading your RC file, since it contains passwords.</p></div><p>To set up launch items/icons, first experiment on your command line
5811
6076
    to find exactly what command works. For example, <div class="informalexample"><pre class="screen">
5812
6077
    java -cp /path/to/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing --urlid mem</pre></div> Then, use your window manager to add an item that
5813
 
    runs this command.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A38"></a>Using the current DatabaseManagers with an older HSQLDB
 
6078
    runs this command.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12B68"></a>Using the current DatabaseManagers with an older HSQLDB
5814
6079
    distribution.</h2></div></div><div></div></div><p>This procedure will allow users of a legacy version of HSQLDB to
5815
6080
    use all of the new features of the DatabaseManagers. You will also get the
5816
6081
    new version of the SqlTool! This procedure works for distros going back to
5827
6092
    Postgresql and a local application. <div class="informalexample"><pre class="screen">
5828
6093
CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/myapp/classes:/usr/local/lib/pg.jdbc3.jar
5829
6094
export CLASSPATH
5830
 
java org.hsqldb.util.DatabaseManagerSwing --urlid urlid</pre></div></p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12A6A"></a>DatabaseManagerSwing as an Applet</h2></div></div><div></div></div><p>
 
6095
java org.hsqldb.util.DatabaseManagerSwing --urlid urlid</pre></div></p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12B9A"></a>DatabaseManagerSwing as an Applet</h2></div></div><div></div></div><p>
5831
6096
          DatabaseManagerSwing is also an applet.
5832
6097
          You can use it in HTML, JSPs, etc.
5833
6098
          Be aware that in Applet mode, actions to load or save local files
5874
6139
              </dd><dt><span class="term">showToolTips</span></dt><dd>
5875
6140
                  Show help hover-text.  Boolean value.  Defaults to true.
5876
6141
              </dd></dl></div>
5877
 
      </p></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12AC8"></a>Appendix&nbsp;G.&nbsp;Transfer Tool</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/06/29 23:15:13 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N12AE5">Brief Introduction</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12AE5"></a>Brief Introduction</h2></div></div><div></div></div><p>Transfer Tool is a GUI program for transferring SQL schema and data
 
6142
      </p></div></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12BF8"></a>Appendix&nbsp;G.&nbsp;Transfer Tool</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Fred</span> <span class="surname">Toussi</span></h3><div class="affiliation"><span class="orgname">HSQLDB Development Group<br></span></div><tt class="email">&lt;<a href="mailto:ft@cluedup.com">ft@cluedup.com</a>&gt;</tt></div></div></div><div><p class="pubdate">$Date: 2005/06/29 23:15:13 $</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#N12C15">Brief Introduction</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N12C15"></a>Brief Introduction</h2></div></div><div></div></div><p>Transfer Tool is a GUI program for transferring SQL schema and data
5878
6143
    from one JDBC source to another. Source and destination can be different
5879
6144
    database engines or different databases on the same server.</p><p>Transfer Tool works in two different modes. Direct transfer
5880
6145
    maintains a connection to both source and destination and performs the