Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > ab9249143a29dc778210513bee340ea1 > files > 219

hsqldb-manual-2.4.0-2.mga7.noarch.rpm

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter&nbsp;11.&nbsp;System Management</title>
<link href="../docbook.css" type="text/css" rel="stylesheet">
<meta content="DocBook XSL-NS Stylesheets V1.76.1" name="generator">
<meta name="keywords" content="Hsqldb, HyperSQL, SQL">
<meta name="keywords" content="Hsqldb, HyperSQL, Database, JDBC, Java">
<link rel="home" href="index.html" title="HyperSQL User Guide">
<link rel="up" href="index.html" title="HyperSQL User Guide">
<link rel="prev" href="builtinfunctions-chapt.html" title="Chapter&nbsp;10.&nbsp;Built In Functions">
<link rel="next" href="compatibility-chapt.html" title="Chapter&nbsp;12.&nbsp;Compatibility With Other DBMS">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table summary="Navigation header" width="100%">
<tr>
<td align="left" width="30%"><a accesskey="p" href="builtinfunctions-chapt.html"><img src="../images/db/prev.png" alt="Prev"></a>&nbsp;</td><td align="center" width="40%" style="font-weight:bold;">Chapter&nbsp;11.&nbsp;System Management</td><td align="right" width="30%">&nbsp;<a accesskey="n" href="compatibility-chapt.html"><img src="../images/db/next.png" alt="Next"></a></td>
</tr>
<tr>
<td valign="top" align="left" width="30%">Chapter&nbsp;10.&nbsp;Built In Functions&nbsp;</td><td align="center" width="40%"><a accesskey="h" href="index.html"><img src="../images/db/home.png" alt="Home"></a></td><td valign="top" align="right" width="30%">&nbsp;Chapter&nbsp;12.&nbsp;Compatibility With Other DBMS</td>
</tr>
</table>
</div>
<HR>
<div class="chapter" title="Chapter&nbsp;11.&nbsp;System Management">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="management-chapt"></a>Chapter&nbsp;11.&nbsp;System Management</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">The HSQL Development Group<br>
</span>
</div>
</div>
</div>
</div>
<div>
<p class="releaseinfo">$Revision: 5746 $</p>
</div>
<div>
<div class="legalnotice" title="Legal Notice">
<a name="N14729"></a>
<p>Copyright 2002-2017 Fred Toussi. Permission is granted to
      distribute this document without any alteration under the terms of the
      HSQLDB license. Additional permission is granted to the HSQL Development
      Group to distribute this document with or without alterations under the
      terms of the HSQLDB license.</p>
</div>
</div>
<div>
<p class="pubdate">2017-04-09 14:14:09-0400</p>
</div>
</div>
</div>
<div class="toc">
<p>
<b>Table of Contents</b>
</p>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_modes_tables">Modes of Operation</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_modes_operation">Deployment Types</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#N14755">Database Types</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_table_types">Tables</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_large_objects">Large Objects</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_deploy_context">Deployment context</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="management-chapt.html#mtc_acid_persistence">ACID, Persistence and Reliability</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_acid">Atomicity, Consistency, Isolation, Durability</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#N14818">System Operations</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="management-chapt.html#mtc_backup">Backing Up and Restoring Database Catalogs</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_online_backup">Making Online Backups</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_backup_syntax">Offline Backup Utility Syntax</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_offline_backup">Making Offline Backups</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_listing_backup">Examining Backups</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_restoring_backup">Restoring a Backup</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="management-chapt.html#mtc_encrypted_database">Encrypted Databases</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_encrypted_create">Creating and Accessing an Encrypted Database</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_encrypted_speed">Speed Considerations</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_encrypted_security">Security Considerations</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="management-chapt.html#mtc_monitoring_operation">Monitoring Database Operations</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_external_monitoring">External Statement Level Monitoring</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_internal_monitoring">Internal Statement Level Monitoring</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_internal_event_monitoring">Internal Event Monitoring</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_jdc_logging">Log4J and JDK logging</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_server_monitoring">Server Operation Monitoring</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="management-chapt.html#mtc_database_security">Database Security</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_security_recommend">Basic Security Recommendations</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_security_defaults">Beyond Security Defaults</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_authentication_control">Authentication Control</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="management-chapt.html#mtc_statements">Statements</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="management-chapt.html#mtc_system_operations">System Operations</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_database_settings">Database Settings</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_sql_settings">SQL Conformance Settings</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_cache_persistence">Cache, Persistence and Files Settings</a></span>
</dt>
<dt>
<span class="section"><a href="management-chapt.html#mtc_authntication_settings">Authentication Settings</a></span>
</dt>
</dl>
</dd>
</dl>
</div>
<div class="section" title="Modes of Operation">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_modes_tables"></a>Modes of Operation</h2>
</div>
</div>
</div>
<p>HyperSQL has many modes of operation and features that allow it to
    be used in very different scenarios. Levels of memory usage, speed and
    accessibility by different applications are influenced by how HyperSQL is
    deployed.</p>
<div class="section" title="Deployment Types">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_modes_operation"></a>Deployment Types</h3>
</div>
</div>
</div>
<p>The decision to run HyperSQL as a separate server process or as an
      <em class="glossterm">in-process</em> database should be based on the
      following:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>When HyperSQL is run as a server on a separate machine, it
            is isolated from hardware failures and crashes on the hosts
            running the application.</p>
</li>
<li class="listitem">
<p>When HyperSQL is run as a server on the same machine, it is
            isolated from application crashes and memory leaks.</p>
</li>
<li class="listitem">
<p>Server connections are slower than
            <em class="glossterm">in-process</em> connections due to the overhead
            of streaming the data for each JDBC call.</p>
</li>
<li class="listitem">
<p>You can access a Server from outside the main application
            and perform backups and other maintenance operations.</p>
</li>
<li class="listitem">
<p>You can reduce client/server traffic using SQL Stored
            procedures to reduce the number of JDBC execute calls.</p>
</li>
<li class="listitem">
<p>During development, it is better to use a Server with
            server.silent=false, which displays the statements sent to the
            server on the console window.</p>
</li>
<li class="listitem">
<p>To improve speed of execution for statements that are
            executed repeatedly, reuse a parameterized PreparedStatement for
            the lifetime of the connections.</p>
</li>
</ul>
</div>
</div>
<div class="section" title="Database Types">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="N14755"></a>Database Types</h3>
</div>
</div>
</div>
<p>There are three types of database, <code class="literal">mem:</code>,
      <code class="literal">file:</code> and <code class="literal">res:</code>. The mem: type is
      stored all in memory and not persisted to file. The
      <code class="literal">file:</code> type is persisted to file. The
      <code class="literal">res:</code> type is also based on files, but the files are
      loaded from the classpath, similar to resource and class files. Changes
      to the data in <code class="literal">file:</code> databases are persisted, unless
      the database is <code class="literal">readonly</code>, or
      <code class="literal">files_readonly</code> (using optional property settings).
      Changes to <code class="literal">res:</code> databases are not persisted.</p>
<div class="section" title="Readonly Databases">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mtc_readonly_database"></a>Readonly Databases</h4>
</div>
</div>
</div>
<p>A <em class="glossterm">file:</em> catalog can be made readonly
        permanently, or it can be opened as readonly. To make the database
        readonly, the property, value pair, <code class="literal">readonly=true</code>
        can be added to the <code class="filename">.properties</code> file of the
        database. The SHUTDOWN command must be used to close the database
        before making this change.</p>
<p>It is also possible to open a normal database as readonly. For
        this, the property can be included in the URL of the first connection
        to the database.</p>
<p>With readonly databases, it is still possible to insert and
        delete rows in TEMP tables.</p>
</div>
<div class="section" title="RES and Files Readonly Databases">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="N14788"></a>RES and Files Readonly Databases</h4>
</div>
</div>
</div>
<p>There is another option which allows MEMORY tables to be
        writeable, but without persisting the changes at SHUTDOWN. This option
        is activated with the property, value pair,
        <code class="literal">files_readonly=true</code>, which can be added to the
        <code class="filename">.properties</code> file of the database, or included in
        the URL of the first connection to the database.</p>
<p>A <em class="glossterm">res:</em> catalog, is a set of database
        files on the classpath (inside a jar or alongside class files). The
        database is opened with a URL in the form of
        <code class="literal">jdbc:hsqldb:res:&lt;database path&gt;</code>. These
        databases are always <code class="literal">files_readonly</code> and have the
        same restrictions as <code class="literal">files_readonly</code>
        <em class="glossterm">file:</em> catalogs.</p>
<p>CACHED tables and LOBS in these catalogs are readonly. It is not
        possible to create new LOBs in these catalogs, but you can use
        existing LOBs in new rows.</p>
<p>These options are useful for running application tests which
        operate on a predefined dataset.</p>
</div>
</div>
<div class="section" title="Tables">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_table_types"></a>Tables</h3>
</div>
</div>
</div>
<p>TEXT tables are designed for special applications where the data
      has to be in an interchangeable format, such as CSV (comma separated
      values). TEXT tables should not be used for routine storage of data that
      changes a lot.</p>
<p>MEMORY tables and CACHED tables are generally used for data
      storage. The difference between the two is as follows:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>The data for all MEMORY tables is read from the *.script
            file when the database is started and stored in memory. In
            contrast the data for cached tables is not read into memory until
            the table is accessed. Furthermore, only part of the data for each
            CACHED table is held in memory, allowing tables with more data
            than can be held in memory.</p>
</li>
<li class="listitem">
<p>When the database is shutdown in the normal way, all the
            data for MEMORY tables is written out to the disk. In comparison,
            the data in CACHED tables that has changed is written out during
            operation and at shutdown.</p>
</li>
<li class="listitem">
<p>The size and capacity of the data cache for all the CACHED
            tables is configurable. This makes it possible to allow all the
            data in CACHED tables to be cached in memory. In this case, speed
            of access is good, but slightly slower than MEMORY tables.</p>
</li>
<li class="listitem">
<p>For normal applications it is recommended that MEMORY tables
            are used for small amounts of data, leaving CACHED tables for
            large data sets. For special applications in which speed is
            paramount and a large amount of free memory is available, MEMORY
            tables can be used for large tables as well.</p>
</li>
<li class="listitem">
<p>You can change the type of the table with the <code class="literal">SET
            TABLE &lt;table name&gt; TYPE { CACHED | MEMORY
            }</code>statement.</p>
</li>
</ul>
</div>
</div>
<div class="section" title="Large Objects">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_large_objects"></a>Large Objects</h3>
</div>
</div>
</div>
<p>HyperSQL 2.0 supports dedicated storage and access to BLOB and
      CLOB objects. These objects can have huge sizes. BLOB or CLOB is
      specified as the type of a column of the table. Afterwards, rows can be
      inserted into the table using a PreparedStatement for efficient transfer
      of large LOB data to the database. In <em class="glossterm">mem:</em>
      catalogs, CLOB and BLOB data is stored in memory. In
      <em class="glossterm">file:</em> catalogs, this data is stored in a single
      separate file which has the extension *.lobs. The size of this file can
      grow to huge, terabyte figures. By default, a minimum 32 KB is allocated
      to each LOB. You can reduced this if your LOBs are generally
      smaller.</p>
<p>LOB data should be stored in the database using a JDBC
      PreparedStatement object. The streaming methods send the LOB to the
      database in one operation as a binary or character stream. Inside the
      database, the disk space is allocated as needed and the data is saved as
      it is being received. LOB data should be retrieved from the database
      using a JDBC ResultSet method. When a streaming method is used to
      retrieve a LOB, it is retrieved in large chunks in a transparent manner.
      LOB data can also be retrieved as String or byte[], but these methods
      use more memory and may not be practical for large objects.</p>
<p>LOB data is not duplicated in the database when a lob is copied
      from one table to another. The disk space is reused when a LOB is
      deleted and is no longer contained in any table. This happens only at
      the time of a CHECKPOINT.</p>
<p>By using a dedicated LOB store, HyperSQL achieves consistently
      high speeds (usually over 20MB / s) for both storage and retrieval of
      LOBs.</p>
<p>There is an internal LOBS schema in the database to store the
      id's, sizes and addresses of the LOBs (but not the actual LOBS) in a few
      system tables. This schema is stored in the database as MEMORY tables.
      Therefore the amount of JVM memory should be increased when more than
      tens of thousands of LOBs are stored in the database. If your database
      contains more than a few hundreds of thousands of LOBs and memory use
      becomes an issue, you can change one or all LOB schema tables to CACHED
      tables. See statements below:</p>
<div class="example">
<a name="N147D8"></a>
<p class="title">
<b>Example&nbsp;11.1.&nbsp;Using CACHED tables for the LOB schema</b>
</p>
<div class="example-contents">
<pre class="screen"> SET TABLE SYSTEM_LOBS.BLOCKS TYPE CACHED
 SET TABLE SYSTEM_LOBS.LOBS TYPE CACHED
 SET TABLE SYSTEM_LOBS.PARTS TYPE CACHED
 SET TABLE SYSTEM_LOBS.LOB_IDS TYPE CACHED
</pre>
</div>
</div>
<br class="example-break">
</div>
<div class="section" title="Deployment context">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_deploy_context"></a>Deployment context</h3>
</div>
</div>
</div>
<p>The files used for storing HyperSQL database data are all in the
      same directory. New files are always created and deleted by the database
      engine. Two simple principles must be observed:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>The Java process running HyperSQL must have full privileges on
          the directory where the files are stored. This include create and
          delete privileges.</p>
</li>
<li class="listitem">
<p>The file system must have enough spare room both for the
          'permanent' and 'temporary' files. The default maximum size of the
          *.log file is 50MB. The *.data file can grow to up to 64GB (more if
          the default has been increased). The .backup file can be up to the
          size of the *.data file. The *.lobs file can grow to several
          terabytes. The temporary files created at the time of a SHUTDOWN can
          be equal in size to the *.script file and the .data file.</p>
</li>
<li class="listitem">
<p>In desktop deployments, virus checker programs may interfere
          with the creation and modification of database files. You should
          exclude the directory containing the database files from virus
          checking.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section" title="ACID, Persistence and Reliability">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_acid_persistence"></a>ACID, Persistence and Reliability</h2>
</div>
</div>
</div>
<p>HyperSQL's persistence mechanism has proven reliable, as the last
    critical issue was fixed 2 years before the release of version 2.0.</p>
<p>There are further enhancements in the latest version.</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>More extensive locking mechanism has been added to code to
        support multithreaded access.</p>
</li>
<li class="listitem">
<p>Incremental backup (an internal mechanism for crash protection)
        allows fast checkpoint and shutdown.</p>
</li>
<li class="listitem">
<p>All files are synced at checkpoints and also just before
        closing.</p>
</li>
<li class="listitem">
<p>The data file is enlarged in block increments</p>
</li>
<li class="listitem">
<p>The NIO file access implementation has been improved</p>
</li>
</ul>
</div>
<p>Persistence relies on the JVM, the operating system, and the
    computer hardware. A database system like HSQLDB can perform millions of
    read and write operations in an hour. As system hardware and software can
    go wrong, it is impossible to achieve zero failure rate. Therefore regular
    backups are recommended. HyperSQL 2.3 has built-in database backup and
    restore features, discussed elsewhere in this chapter.</p>
<p>A note regarding the NIO file access implementation: This
    implementation applies only to CACHED table data in the
    <code class="literal">.data</code> file. Other files are not accessed via NIO. There
    has been an issue with some JVM implementations of nio not releasing the
    file buffers after they were closed. HyperSQL uses a workaround which is
    recommended for Sun JVM's. This does not apply to other JVM's. In such
    environments, it is therefore recommended to test the CHECKPOINT DEFRAG
    operation and the shutting down and restarting the database inside the
    same Java process extensively with NIO. Use of NIO is not essential and
    can be turned off if necessary.</p>
<div class="section" title="Atomicity, Consistency, Isolation, Durability">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_acid"></a>Atomicity, Consistency, Isolation, Durability</h3>
</div>
</div>
</div>
<p>Atomicity means a transaction either fails without changing the
      data, or succeeds. HyperSQL ensures atomicity both during operations and
      in the event of a system crash.</p>
<p>Consistency means all the implicit and explicit integrity
      constraints are always enforced. HyperSQL always enforces the
      constraints and at the same time does not allow unenforceable
      constraints (illegal forms of CHECK constraints) to be created.</p>
<p>Isolation means transactions do not interfere with each other.
      HyperSQL enforces isolation according to strict rules of the database
      isolation model (MVCC or LOCKS).</p>
<p>Durability means a committed transaction is protected in case of a
      system crash. HyperSQL ensures durability according to the setting for
      WRITE DELAY MILLIS. A zero delay setting results in an
      FileDescriptor#sync() call each time a transaction commits. A timed
      delay means the FileDescriptor#sync() call is executed in the given
      intervals and only the last transactions committed in the time interval
      may be lost. The default time interval is 0.5 second. The sync() call is
      also made at all critical points, including when a file is about to be
      closed. Durability of files requires a reliable JVM and disk storage
      system that stores the data safely with a sync() call. In practice, many
      systems are generally reliable in this respect.</p>
</div>
<div class="section" title="System Operations">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="N14818"></a>System Operations</h3>
</div>
</div>
</div>
<p>A database is opened when the first connection is successfully
      made. It remains open until the <code class="literal">SHUTDOWN</code> command is
      issued. If the connection property shutdown=true is used for the first
      connection to the database, the database is shutdown when the last
      connection is closed. Otherwise the database remains open and will
      accept the next connection attempt.</p>
<p>The <code class="literal">SHUTDOWN</code> command shuts down the database
      properly and allows the database to be reopened quickly. This command
      may take some seconds as it saves all the modified data in the
      .<code class="literal">script</code> and <code class="literal">.data</code> files. Variants
      of <code class="literal">SHUTDOWN</code> such as <code class="literal">SHUTDOWN
      COMPACT</code> and <code class="literal">SHUTDOWN SCRIPT</code> can be used
      from time to time to reduce the overall size of the database files.
      Another variant is <code class="literal">SHUTDOWN IMMEDIATELY</code> which ensures
      all changes to data are stored in the <code class="literal">.log</code> file but
      does not save the changes in .<code class="literal">script</code> and
      <code class="literal">.data</code> files. The shutdown is performed quickly but
      the database will take much longer to reopen.</p>
<p>During the lifetime of the database the checkpoint operation may
      be performed from time to time. The <code class="literal">SET FILES LOG SIZE &lt;
      value &gt;</code> setting and its equivalent URL property determine
      the frequency of automatic checkpoints. An online backup also performs a
      checkpoint when the backup is not a hot backup. A checkpoint can be
      performed by the user at any time using the
      <code class="literal">CHECKPOINT</code> statement. The main purpose of checkpoints
      is to reduce the total size of database files and to allow a quick
      restart in case the database is closed without a proper shutdown. The
      <code class="literal">CHECKPOINT DEFRAG</code> variant compacts the
      <code class="literal">.data</code> file in a similar way to <code class="literal">SHUTDOWN
      COMPACT</code> does. Obviously this variant takes much longer than a
      normal <code class="literal">CHECKPOINT</code>. A database setting allows a
      <code class="literal">CHECKPOINT DEFRAG</code> to be performed automatically when
      wasted space in the <code class="literal">.data</code> file exceeds the specified
      percentage.</p>
<p>In a multi-user application, automatic or user-initiated
      checkpoints are delayed until all other sessions have committed or
      rolled back. During a checkpoint, other sessions cannot access the
      database tables but can access the <code class="literal">INFORMATION_SCHEMA</code>
      system tables.</p>
</div>
</div>
<div class="section" title="Backing Up and Restoring Database Catalogs">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_backup"></a>Backing Up and Restoring Database Catalogs</h2>
</div>
</div>
</div>
<a name="N14863" class="indexterm"></a>
<p>The database engine saves the files containing all the data in a
    file catalog when a shutdown takes place. It automatically recovers from
    an abnormal termination and preserves the data when the catalog is opened
    next time. In an ideal operating environment, where there is no OS crash,
    disk failure, bugs in code, etc. there would be no need to backup a
    database. Backing up catalogs is an insurance policy against all sorts of
    misadventure that are not under the control of the database engine.</p>
<p>The data for each catalog consists of up to 5 files in the same
    directory with the endings such as <code class="literal">*.properties</code>,
    <code class="literal">*.script</code>, etc., as detailed in previous
    chapters.</p>
<p>HyperSQL 2 includes commands to backup the database files into a
    single <code class="literal">.tar</code> or <code class="literal">.tar.gz</code> file archive,
    or alternatively as copies of the database files. The backup can be
    performed by a command given in a JDBC session if the target database
    catalog is running, or on the command-line if the target catalog has been
    shutdown.</p>
<p>It is not recommended to backup the database file with an
    external file backup program while the database is running. The resulting
    backup will probably be inconsistent and not useful for restoring the
    database</p>
<div class="section" title="Making Online Backups">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_online_backup"></a>Making Online Backups</h3>
</div>
</div>
</div>
<p>To back up a running catalog, obtain a JDBC connection and
      issue a <code class="literal">BACKUP DATABASE</code> command in SQL. In its most
      simple form, the command format below will backup the database as a
      single <code class="literal">.tar.gz</code> file to the given directory. This type
      of backup performs a checkpoint immediately before backing up the
      files.</p>
<pre class="programlisting"> BACKUP DATABASE TO &lt;directory name&gt; BLOCKING [ AS FILES ]</pre>
<p>The <span class="emphasis"><em>directory name</em></span> must end with a slash
      to distinguish it as a directory, and the whole string must be in single
      quotes like so: <code class="literal">'subdir/nesteddir/'</code>.</p>
<p>Normal backup may take a long time with very large databases.
      Hot backup may be used in those situations. This type of backup does not
      perform a checkpoint and allows access to the database while backup is
      in progress.</p>
<pre class="programlisting"> BACKUP DATABASE TO &lt;directory name&gt; NOT BLOCKING [ AS FILES ]</pre>
<p>If you add AS FILES to the statements, the database files are
      backed up as separate files in the directory, without any gzip
      compression or tar archiving.</p>
<p>See the next section under Statements for details about the
      command and its options. See the sections below about restoring a
      backup.</p>
</div>
<div class="section" title="Offline Backup Utility Syntax">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_backup_syntax"></a>Offline Backup Utility Syntax</h3>
</div>
</div>
</div>
<p>The <code class="classname">DbBackup</code> class is used from the
      command-line to make offline backups and to restore backups. Here is how
      to see all options for <code class="classname">DbBackup</code>. </p>
<div class="example">
<a name="N148A5"></a>
<p class="title">
<b>Example&nbsp;11.2.&nbsp;Displaying DbBackup Syntax</b>
</p>
<div class="example-contents">
<pre class="screen"> java -cp hsqldb.jar org.hsqldb.lib.tar.DbBackupMain</pre>
</div>
</div>
<p>
<br class="example-break">
</p>
</div>
<div class="section" title="Making Offline Backups">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_offline_backup"></a>Making Offline Backups</h3>
</div>
</div>
</div>
<p>To back up an offline catalog, the catalog must be in shut down
      state. You will run a Java command like this. In this example, the
      database is named dbname and is in the dbdir directory. The backup is
      saved to a file named backup.tar in the tardir directory.</p>
<div class="example">
<a name="N148B0"></a>
<p class="title">
<b>Example&nbsp;11.3.&nbsp;Offline Backup Example</b>
</p>
<div class="example-contents">
<pre class="screen"> java -cp hsqldb.jar org.hsqldb.lib.tar.DbBackupMain --save tardir/backup.tar dbdir/dbname</pre>
</div>
</div>
<p>
<br class="example-break">where <code class="filename">tardir/backup.tar</code> is a file path
      to the <code class="literal">*.tar</code> or <code class="literal">*.tar.gz</code> file to
      be created in your file system, and <code class="filename">dbdir/dbname</code> is
      the file path to the catalog file base name (in same fashion as in
      <code class="varname">server.database.*</code> settings and JDBC URLs with catalog
      type <em class="glossterm">file:</em>.</p>
</div>
<div class="section" title="Examining Backups">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_listing_backup"></a>Examining Backups</h3>
</div>
</div>
</div>
<p>You can list the contents of backup tar files with
      <code class="classname">DbBackup</code> on your operating system command line,
      or with any Pax-compliant tar or pax client (this includes GNU tar),
      </p>
<div class="example">
<a name="N148D1"></a>
<p class="title">
<b>Example&nbsp;11.4.&nbsp;Listing a Backup with DbBackup</b>
</p>
<div class="example-contents">
<pre class="screen"> java -cp hsqldb.jar org.hsqldb.lib.tar.DbBackupMain --list tardir/backup.tar</pre>
</div>
</div>
<p>
<br class="example-break">You can also give regular expressions at the end of the
      command line if you are only interested in some of the file entries in
      the backup. Note that these are real regular expressions, not shell
      globbing patterns, so you would use <code class="literal">.+script</code> to match
      entries ending in "script", not <code class="literal">*script</code>.</p>
<p>You can examine the contents of the backup in their entirety by
      restoring the backup, as explained in the following section, to a
      temporary directory.</p>
</div>
<div class="section" title="Restoring a Backup">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_restoring_backup"></a>Restoring a Backup</h3>
</div>
</div>
</div>
<p>You use <code class="classname">DbBackup</code> on your operating system
      command line to restore a catalog from a backup. </p>
<div class="example">
<a name="N148E8"></a>
<p class="title">
<b>Example&nbsp;11.5.&nbsp;Restoring a Backup with DbBackup</b>
</p>
<div class="example-contents">
<pre class="screen"> java -cp hsqldb.jar org.hsqldb.lib.tar.DbBackupMain --extract tardir/backup.tar dbdir</pre>
</div>
</div>
<p>
<br class="example-break">where <code class="filename">tardir/backup.tar</code> is a file path
      to the *.tar or *.tar.gz file to be read, and <code class="filename">dbdir</code>
      is the target directory to extract the catalog files into. Note that
      <code class="filename">dbdir</code> specifies a directory path, without the
      catalog file base name. The files will be created with the names stored
      in the tar file (and which you can see as described in the preceding
      section). After restoring the database, you can connect to it as
      usual.</p>
</div>
</div>
<div class="section" title="Encrypted Databases">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_encrypted_database"></a>Encrypted Databases</h2>
</div>
</div>
</div>
<p>HyperSQL supports encrypted databases. Encryption services use the
    Java Cryptography Extensions (JCE) and uses the ciphers installed with the
    JRE. HyperSQL itself does not contain any cryptography code.</p>
<p>Three elements are involved in specifying the encryption method and
    key. A cipher, together with its configuration is identified by a string
    which includes the name of the cipher and optional parameters. A provider
    is the fully qualified class name of the cipher provider. A key is
    represented as a hexadecimal string.</p>
<div class="section" title="Creating and Accessing an Encrypted Database">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_encrypted_create"></a>Creating and Accessing an Encrypted Database</h3>
</div>
</div>
</div>
<p>First, a key must be created for the desired cipher and
      configuration. This is done by calling the function CRYPT_KEY(&lt;cipher
      spec&gt;, &lt;provider&gt;). If the default provider (the built-in JVM
      ciphers) is used, then NULL should be specified as the provider. The
      CRYPT_KEY function returns a hexadecimal key. The function call can be
      made in any HyperSQL database, so long as the provider class is on the
      classpath. This key can be used to create a new encrypted database.
      Calls to this function always return different keys, based on generated
      random values.</p>
<p>As an example, a call to CRYPT_KEY('Blowfish', null) returned the
      string, '604a6105889da65326bf35790a923932'. To create a new database,
      the URL below is used:</p>
<p>
<code class="literal">jdbc:hsqldb:file:&lt;database
      path&gt;;crypt_key=604a6105889da65326bf35790a923932;crypt_type=blowfish</code>
</p>
<p>The third property name is crypt_provider. This is specified only
      when the provider is not the default provider.</p>
<p>HyperSQL works with any symmetric cipher that may be available
      from the JVM.</p>
<p>The files that are encrypted include the .script, .data, .backup
      and .log files. The .lobs file is not encrypted by default. The property
      crypt_lobs=true must be specified to encrypt the .lobs file. When this
      property is used, the blobs and clobs are both compressed and
      encrypted.</p>
</div>
<div class="section" title="Speed Considerations">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_encrypted_speed"></a>Speed Considerations</h3>
</div>
</div>
</div>
<p>General operations on an encrypted database are performed the same
      as with any database. However, some operations are significantly slower
      than with the equivalent cleartext database. With MEMORY tables, there
      is no difference to the speed of SELECT statements, but data change
      statements are slower. With CACHED tables, the speed of all statements
      is slower.</p>
</div>
<div class="section" title="Security Considerations">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_encrypted_security"></a>Security Considerations</h3>
</div>
</div>
</div>
<p>Security considerations for encrypted databases have been
      discussed at length in HSQLDB discussion groups. Development team
      members have commented that encryption is not a panacea for all security
      needs. The following issues should be taken into account:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Encrypted files are relatively safe in transport, but
            because databases contain many repeated values and words,
            especially known tokens such as CREATE, INSERT, etc., breaking the
            encryption of a database may be simpler than an unknown
            file.</p>
</li>
<li class="listitem">
<p>Only the files are encrypted, not the memory image. Poking
            into computer memory, while the database is open, will expose the
            contents of the database.</p>
</li>
<li class="listitem">
<p>HyperSQL is open source. Someone who has the key, can
            compile and use a modified version of the program that saves a
            full cleartext dump of an encrypted database</p>
</li>
</ul>
</div>
<p>Therefore encryption is generally effective only when
      the users who have access to the crypt key are trusted.</p>
</div>
</div>
<div class="section" title="Monitoring Database Operations">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_monitoring_operation"></a>Monitoring Database Operations</h2>
</div>
</div>
</div>
<p>Database operations can be monitored at different levels using
    internal HyperSQL capabilities or add-ons.</p>
<div class="section" title="External Statement Level Monitoring">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_external_monitoring"></a>External Statement Level Monitoring</h3>
</div>
</div>
</div>
<p>Statement level monitoring allows you to gather statistics about
      executed statements. HyperSQL is supported by the monitoring tool JAMon
      (Java Application Monitor). JAMon is currently developed as the
      SourceForge project, jamonapi.</p>
<p>JAMon works at the JDBC level. It can monitor and gather
      statistics on different types of executed statements or other JDBC
      calls.</p>
<p>Early versions of JAMon were developed with HSQLDB and had to be
      integrated into HSQLDB at code level. The latest versions can be added
      on as a proxy in a much simpler fashion.</p>
</div>
<div class="section" title="Internal Statement Level Monitoring">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_internal_monitoring"></a>Internal Statement Level Monitoring</h3>
</div>
</div>
</div>
<p>The internally-generated, individual sql log for the database can
      be enabled with the <code class="literal">SET DATABASE EVENT LOG SQL LEVEL</code>
      statement, described in this chapter. As all the executed statements are
      logged, there is an impact on speed. So you should only use this for
      debugging. Two levels of sql logging are supported.</p>
</div>
<div class="section" title="Internal Event Monitoring">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_internal_event_monitoring"></a>Internal Event Monitoring</h3>
</div>
</div>
</div>
<p>HyperSQL can log important internal events of the engine. These
      events occur during the operation of the engine, and are not always
      coupled with the exact type of statement being executed. Normal events
      such as opening and closing of files, or errors such as OutOfMemory
      conditions are examples of logged events.</p>
<p>HyperSQL supports two methods of logging. One method is specific
      to the individual database and is managed internally by HyperSQL. The
      other method is specific to JVM and is managed by a logging
      framework.</p>
<p>The internally-generated, individual log for the database can be
      enabled with the <code class="literal">SET DATABASE EVENT LOG LEVEL</code>
      statement, described in this chapter. This method of logging is very
      useful for desktop application deployment, as it provides an ongoing
      record of database operations.</p>
</div>
<div class="section" title="Log4J and JDK logging">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_jdc_logging"></a>Log4J and JDK logging</h3>
</div>
</div>
</div>
<p>HyperSQL also supports log4J and JDK logging. The same event
      information that is passed to the internal log, is passed to external
      logging frameworks. These frameworks are typically configured outside
      HyperSQL. The log messages include the string "hsqldb.db." followed by
      the unique id (a 16 character string) of the database that generated the
      message, so they can be identified in a multi-database server
      context.</p>
<p>As the default JDK logging framework has several shortcomings,
      HyperSQL configures this logging framework for better operation. If you
      do not want HyperSQL to configure the JDK logging framework, you should
      include the system level property
      <code class="literal">hsqldb.reconfig_logging=false</code> in your
      environment.</p>
</div>
<div class="section" title="Server Operation Monitoring">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_server_monitoring"></a>Server Operation Monitoring</h3>
</div>
</div>
</div>
<p>A Server or WebServer instance can be started with the property
      server.silent=false. This causes all the connections and their executed
      statements to be printed to stdout as the statements are submitted to
      the server.</p>
</div>
</div>
<div class="section" title="Database Security">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_database_security"></a>Database Security</h2>
</div>
</div>
</div>
<p>HyperSQL has extensive security features which are implemented at
    different levels and covered in different chapters of this guide.</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>The server can use SSL and IP address access control lists. See
        the <a class="link" href="listeners-chapt.html" title="Chapter&nbsp;14.&nbsp;HyperSQL Network Listeners (Servers)">HyperSQL Network Listeners
    (Servers)</a> chapter.</p>
</li>
<li class="listitem">
<p>You can define a system property to stop the database engine
        accessing the Java static functions that are on the classpath, apart
        from a limited set that you allow. See Securing Access to Classes in
        the <a class="link" href="sqlroutines-chapt.html" title="Chapter&nbsp;8.&nbsp;SQL-Invoked Routines">SQL-Invoked Routines</a> chapter.</p>
</li>
<li class="listitem">
<p>You can define a system property to allow access to files on the
        file system outside the database directory and its children. This
        access is only necessary if you use TEXT tables or want to load and
        save files directly to the file system as BLOB or CLOB. See the <a class="link" href="texttables-chapt.html" title="Chapter&nbsp;5.&nbsp;Text Tables">Text Tables</a>
        chapter.</p>
</li>
<li class="listitem">
<p>The database files can be encrypted. Discussed in this
        chapter.</p>
</li>
<li class="listitem">
<p>Within the database, the DBA privileges are required for system
        and maintenance jobs.</p>
</li>
<li class="listitem">
<p>You can define users and roles and grant them access on
        different database objects. Each user has a password and is granted a
        set of privileges. HSQLDB supports table level and column level
        privileges. See the <a class="link" href="accesscontrol-chapt.html" title="Chapter&nbsp;6.&nbsp;Access Control">Access Control</a> chapter.</p>
</li>
<li class="listitem">
<p>You can define a password complexity check function for new and
        changed passwords. This is covered below under Authentication
        Settings.</p>
</li>
<li class="listitem">
<p>You can use external authentication such as LDAP instead of
        internally stored password to authenticate users for each database.
        This is covered below under Authentication Settings.</p>
</li>
</ol>
</div>
<p>HyperSQL security is multi-layered and avoids any loopholes to
    circumvent security. It is however the user's responsibility to enable the
    required level of security.</p>
<div class="section" title="Basic Security Recommendations">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_security_recommend"></a>Basic Security Recommendations</h3>
</div>
</div>
</div>
<p>The default setting are generally adequate for embedded use of the
      database in single-user applications. For servers on the host that are
      accessed from the same machine or accessed within a network, and
      especially for those accessed from outside the network, additional
      security settings must be used. This is the minimum list of changes you
      need to make:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Change the admin password. Change the admin name (the default
          is SA) as well for extra security.</p>
</li>
<li class="listitem">
<p>Create a non-admin user for normal database access and grant
          the required SELECT, INSERT, UPDATE and DELETE privileges to this
          user. Connect with this user's credentials from the
          application.</p>
</li>
<li class="listitem">
<p>Set up SSL and IP address access control on the Server.</p>
</li>
<li class="listitem">
<p>Restrict the execution of multiple statements with
          <code class="literal">SET DATABASE SQL RESTRICT EXEC TRUE</code> .</p>
</li>
<li class="listitem">
<p>Backup the database regularly and store the backups in a
          different location than the machine running the Server.</p>
</li>
</ul>
</div>
</div>
<div class="section" title="Beyond Security Defaults">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_security_defaults"></a>Beyond Security Defaults</h3>
</div>
</div>
</div>
<p>The default settings for server and web server do not use SSL or
      IP access control lists. These features are enabled programatically, or
      with the properties used to start the server.</p>
<p>The default settings allow a database user with the DBA role or
      with schema creation role to access static functions on the classpath.
      You can disable this feature or limit it to specific classes and
      methods. This can be done programatically or by setting a system
      property when you start a server.</p>
<p>If access to specific static functions is granted, then these
      functions must be considered as part of the database program and checked
      for any security flaws before inclusion in the classpath.</p>
<p>The default settings do not allow a user to access files outside
      the database directory. This access is for TEXT table source files. You
      can override this programatically or with a system property when you
      start a server.</p>
<p>The encryption of database file does not utilise any user-supplied
      information for encryption keys. This level of security is outside the
      realm of users and passwords.</p>
<p>The first user for a new database has the DBA role. This user name
      was always SA in older versions of HSQLDB, but not in the latest
      versions. The name of the first DBA user and its password can be
      specified when the database is created by the first connection to the
      database. These settings are then stored in the database. You can also
      change the name after creating the database.</p>
<p>The initial user with the DBA role should be used for admin
      purposes only. At least one additional role should be created for normal
      database use in the application and at least one additional user should
      be created and granted this role. The new role should not be given the
      DBA role. It can be given the CREATE_SCHEMA role, which allows it to
      create and access multiple schemas. Alternatively, the user with the DBA
      role can create the schemas and their objects and then grant specific
      privileges on the objects to the non-DBA role.</p>
</div>
<div class="section" title="Authentication Control">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_authentication_control"></a>Authentication Control</h3>
</div>
</div>
</div>
<p>Authentication is the mechanism that determines if a user can
      access the database at all. Once authentication is performed, the
      authorization mechanism is used to determine which database objects the
      particular user can access. The default authentication mechanism is
      password authentication. Each user is created with a password, which is
      stored as a hash in the database and checked each time a new database
      connection is created.</p>
<a name="N149C1" class="indexterm"></a>
<p>
<span class="bold"><strong>Password Complexity
      Check</strong></span>
</p>
<p>HyperSQL allows you to define a function that checks the quality
      of the passwords defined in the database. The passwords are stored in
      the database. Each time a user connects, the user's name and password
      are checked against the stored list of users and passwords. The
      connection attempt is rejected if there is no match.</p>
<a name="N149CC" class="indexterm"></a>
<p>
<span class="bold"><strong>External
      Authentication</strong></span>
</p>
<p>You can use an external authentication mechanism instead of the
      internal authentication mechanism. HyperSQL allows you to define a
      function that checks the combination of database unique name, user name,
      and password for each connection attempt. The function can use external
      resources to authenticate the user. For example, a directory server may
      be used. The password may be ignored if the external resource can verify
      the user's credential without it.</p>
<p>You can override external authentication for a user with the ALTER
      USER statement. See the <a class="link" href="accesscontrol-chapt.html" title="Chapter&nbsp;6.&nbsp;Access Control">Access Control</a> chapter</p>
</div>
</div>
<div class="section" title="Statements">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="mtc_statements"></a>Statements</h2>
</div>
</div>
</div>
<p>System level statements are listed in this section. Statements that
    begin with SET DATABASE or SET FILES are for properties that have an
    effect on the normal operation of HyperSQL. The effects of these
    statements are also discussed in different chapters.</p>
<div class="section" title="System Operations">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_system_operations"></a>System Operations</h3>
</div>
</div>
</div>
<p>These statements perform a system level action.</p>
<a name="N149E9" class="indexterm"></a>
<p>
<span class="bold"><strong>SHUTDOWN</strong></span>
</p>
<p>
<span class="emphasis"><em>shutdown statement</em></span>
</p>
<p>
<code class="literal">&lt;shutdown statement&gt; ::= SHUTDOWN [IMMEDIATELY |
      COMPACT | SCRIPT]</code>
</p>
<p>Shutdown the database. If the optional qualifier is not used, a
      normal SHUTDOWN is performed. A normal SHUTDOWN ensures all data is
      saved correctly and the database opens without delay on next
      use.</p>
<div class="variablelist">
<table border="0">
<col valign="top" align="left">
<tbody>
<tr>
<td>
<p>
<span class="term">SHUTDOWN</span>
</p>
</td><td>
<p>Normal shutdown saves all the database files, then deletes
            the .log file (and the .backup file in the default mode). This
            does the same thing as CHECKPOINT, but closes the database when it
            completes. The database opens without delay on next used.</p>
</td>
</tr>
<tr>
<td>
<p>
<span class="term">SHUTDOWN IMMEDIATELY</span>
</p>
</td><td>
<p>Saves the *.log file and closes the database files. This is
            the quickest form of shutdown. This command should not be used as
            the routine method of closing the database, because when the
            database is accessed next time, it may take a long time to
            start.</p>
</td>
</tr>
<tr>
<td>
<p>
<span class="term">SHUTDOWN COMPACT</span>
</p>
</td><td>
<p>This is similar to normal SHUTDOWN, but reduces the *.data
            file to its minimum size. It can take much longer than normal
            SHUTDOWN. This shouldn't be used as routine.</p>
</td>
</tr>
<tr>
<td>
<p>
<span class="term">SHUTDOWN SCRIPT</span>
</p>
</td><td>
<p>This is similar to SHUTDOWN COMPACT, but it does not rewrite
            the <code class="literal">*.data</code> and text table files. After SHUTDOWN
            SCRIPT, only the <code class="literal">*.script</code> and
            <code class="literal">*.properties</code> files remain. At the next startup,
            these files are processed and the <code class="literal">*.data</code> file
            is created if there are cached tables. This command in effect
            performs part of the job of SHUTDOWN COMPACT, leaving the other
            part to be performed automatically at the next startup.</p>
<p>This command produces a full script of the database which
            can be edited for special purposes prior to the next
            startup.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N14A23" class="indexterm"></a>
<p>
<span class="bold"><strong>BACKUP DATABASE</strong></span>
</p>
<p>
<span class="emphasis"><em>backup database statement</em></span>
</p>
<p>
<code class="literal">&lt;backup database statement&gt; ::= BACKUP DATABASE
      TO &lt;file path&gt; [SCRIPT] {[NOT] COMPRESSED} {[NOT] BLOCKING} [AS
      FILES]</code>
</p>
<p>Backup the database to specified <code class="literal">&lt;file
      path&gt;</code> for archiving purposes.</p>
<p>The <code class="literal">&lt;file path&gt;</code> can be in two forms.
      If the <code class="literal">&lt;file path&gt;</code> ends with a forward slash,
      it specifies a directory. In this case, an automatic name for the
      archive is generated that includes the date, time and the base name of
      the database. The database is backed up to this archive file in the
      specified directory. The archive is in <code class="literal">.tar.gz</code> or
      <code class="literal">.tar</code> format depending on whether it is compressed or
      not.</p>
<p>If the <code class="literal">&lt;file path&gt;</code> does not end with a
      forward slash, it specifies a user-defined file name for the backup
      archive. The file extension must be either <code class="literal">.tar.gz</code> or
      <code class="literal">.tar</code> and this must match the compression
      option.</p>
<p>The default set of options is COMPRESSED BLOCKING.</p>
<p>If SCRIPT is specified, the backup will contain a
      <code class="literal">*.script</code> file, which contain all the data and
      settings of the database. This type of backup is suitable for smaller
      databases. With larger databases, this takes a long time. When the
      SCRIPT option is no used, the backup set will consist of the current
      snapshot of all database files.</p>
<p>If NOT COMPRESSED is specified, the backup is a tar file,
      without compression. Otherwise, it is in gzip format.</p>
<p>The qualifier, BLOCKING, means all database operations are
      suspended during backup. During backup, a CHECKPOINT command is silently
      executed. This mode is always used when SCRIPT is specified.</p>
<p>Hot backup is performed if NOT BLOCKING is specified. In this
      mode, the database can be used during backup. This mode should only be
      used with very large databases. A hot backup set is less compact and
      takes longer to restore and use than a normal backup set produced with
      the BLOCKING option. You can perform a CHECKPOINT just before a hot
      backup in order to reduce the size of the backup set.</p>
<p>If AS FILES is specified, the database files are copied to a
      directory specified by &lt;file path&gt; without any compression. The
      file path must be a directory. If the directory does not exist, it is
      created. The file path may be absolute or relative. If it is relative,
      it is interpreted as relative to the location of database files. When AS
      FILES is specified, SCRIPT or COMPRESSED options are not available. The
      backup can be performed as BLOCKING or NOT BLOCKING.</p>
<p>The HyperSQL jar also contains a program that creates an
      archive of an offline database. It also contains a program to expand an
      archive into database files. These programs are documented in this
      chapter under Backing up Database Catalogs.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N14A63" class="indexterm"></a>
<p>
<span class="bold"><strong>CHECKPOINT</strong></span>
</p>
<p>
<span class="emphasis"><em>checkpoint statement</em></span>
</p>
<p>
<code class="literal">&lt;checkpoint statement&gt; ::= CHECKPOINT
      [DEFRAG]</code>
</p>
<p>Closes the database files, rewrites the script file, deletes
      the log file and reopens the database.</p>
<p>If <code class="literal">DEFRAG</code> is specified, also shrinks the
      <code class="literal">*.data</code> file to its minimum size. <code class="literal">CHECKPOINT
      DEFRAG</code> time depends on the size of the database and can take a
      long time with huge databases.</p>
<p>A checkpoint on a multi-user database waits until all other
      sessions have committed or rolled back. While the checkpoint is in
      progress other sessions are kept waiting. Checkpoint does not close any
      sessions.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N14A83" class="indexterm"></a>
<p>
<span class="bold"><strong>SCRIPT</strong></span>
</p>
<p>
<span class="emphasis"><em>script statement</em></span>
</p>
<p>
<code class="literal">&lt;script statement&gt; ::= SCRIPT [&lt;file
      name&gt;]</code>
</p>
<p>Returns a script containing SQL statements that define the
      database, its users, and its schema objects. If <code class="literal">&lt;file
      name&gt;</code> is not specified, the statements are returned in a
      ResultSet, with each row containing an SQL statement. No data statements
      are included in this form. The optional file name is a single-quoted
      string. If <code class="literal">&lt;file name&gt;</code> is specified, then the
      script is written to the named file. In this case, all the data in all
      tables of the database is included in the script as INSERT
      statements.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
</div>
<div class="section" title="Database Settings">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_database_settings"></a>Database Settings</h3>
</div>
</div>
</div>
<p>These statements change the database settings.</p>
<a name="N14AA2" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE
      COLLATION</strong></span>
</p>
<p>
<span class="emphasis"><em>set database collation statement</em></span>
</p>
<p>
<code class="literal">&lt;set database collation statement&gt; ::= SET
      DATABASE COLLATION &lt;collation name&gt; [ NO PAD | PAD SPACE
      ]</code>
</p>
<p>Each database can have its own default collation. Sets the
      collation from the set of collations supported by HyperSQL. Once this
      command has been issued, the database can be opened in any JVM and will
      retain its collation.</p>
<p>All collations pad the shorter string with spaces when two
      strings are compared. If NO PAD is specified, comparison is performed
      without padding. The default system collation is named
      <code class="literal">SQL_TEXT</code>. To use the default without padding use
      <code class="literal">SET DATABASE COLLATION SQL_TEXT NO PAD</code>.</p>
<p>After you change the collation for a database that contains
      collated data, you must execute <code class="literal">SHUTDOWN COMPACT</code> or
      <code class="literal">SHUTDOWN SCRIPT</code> in order to recreate the
      indexes.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>Collations are discussed in the <a class="link" href="databaseobjects-chapt.html" title="Chapter&nbsp;4.&nbsp;Schemas and Database Objects">Schemas and Database Objects</a> chapter. Some examples of
      setting the database collation follow:</p>
<pre class="programlisting"> -- this collation is an ascii collation with Upper Case Comparison (coverts strings to uppercase for comparison)
 SET DATABASE COLLATION SQL_TEXT_UCC

 -- this collation is case-insensitive English
 SET DATABASE COLLATION "English 1"
 -- this collation is case-sensitive French
 SET DATABASE COLLATION "French 2"  </pre>
<a name="N14ACE" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE DEFAULT RESULT MEMORY
      ROWS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database default result memory rows
      statement</em></span><code class="literal"> </code>
</p>
<p>
<code class="literal">&lt;set database default result memory rows&gt; ::=
      SET DATABASE DEFAULT RESULT MEMORY ROWS &lt;unsigned integer
      literal&gt;</code>
</p>
<p>Sets the maximum number of rows of each result set and internal
      temporary table that is held in memory. Temporary tables includes views,
      schema-based and session-based TEMPORARY tables, transient tables for
      subqueries, and <code class="literal">INFORMATION_SCHEMA</code> tables.</p>
<p>This setting applies to all sessions. Individual sessions can
      change the value with the <code class="literal">SET SESSION RESULT MEMORY
      ROWS</code> statement. The default is 0, meaning all result sets are
      held in memory.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.result_max_memory_rows</code>.</p>
<a name="N14AF0" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE DEFAULT TABLE
      TYPE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database default table type
      statement</em></span><code class="literal"> </code>
</p>
<p>
<code class="literal">&lt;set database default table type&gt; ::= SET
      DATABASE DEFAULT TABLE TYPE { CACHED | MEMORY }</code>
</p>
<p>Sets the type of table created when the next CREATE TABLE
      statement is executed. The default is MEMORY.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.default_table_type</code>.</p>
<a name="N14B0A" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE EVENT LOG
      LEVEL</strong></span>
</p>
<p>
<span class="emphasis"><em>set database event log level
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database event log level&gt; ::= SET DATABASE
      EVENT LOG [ SQL ] LEVEL { 0 | 1 | 2 | 3 }</code>
</p>
<p>When the SQL option is not used, this statement sets the amount
      of information logged in the internal, database-specific event log.
      Level 0 means no log. Level 1 means only important (error) events. Level
      2 means more events, including both important and less important
      (normal) events. Level 3 includes even more details. For readonly and
      <em class="glossterm">mem:</em> databases, if the level is set above 0, the
      log messages are directed to stderr.</p>
<p>The events are logged in a file with the extension
      <code class="literal">.app.log</code> alongside the main database files.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.applog</code>.</p>
<p>When the SQL option is used, this statement logs the SQL
      statements as they are executed. Each log line contains the timestamp
      and the session number, followed by the SQL statement and JDBC arguments
      if any.</p>
<p>Levels 1, 2 and 3 are supported. Level 1 only logs commits and
      rollbacks, while Level 2 and 3 log all statements. Level 2 truncates
      long statements, while level 3 reports the full statement and parameter
      values.</p>
<p>The logged lines are stored in a file with the extension
      <code class="literal">.sql.log</code> alongside the main database files.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.sqllog</code>.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>From version 2.3, the equivalent URL properties,
      <code class="literal">hsqldb.app_log</code> and <code class="literal">hsqldb.sql_log</code>,
      can be used not only for a new database, but also when opening an
      existing file database to change the event log level.</p>
<p>An extract from an .sql.log file created with log Level 3 is
      shown below. The numbers after the timestamp (10 and 1) show the session
      number. The values for prepared statement parameters are shown in
      parentheses at the end of the statement.</p>
<div class="example">
<a name="N14B42"></a>
<p class="title">
<b>Example&nbsp;11.6.&nbsp;SQL Log Example</b>
</p>
<div class="example-contents">
<pre class="screen"> 2012-11-29 10:40:40.250 10 INSERT INTO TEST_CLOB VALUES (1,'Ut wisi enim ad minim veniam, quis nostrud exerci') 
 2012-11-29 10:40:40.250 1 INSERT INTO SYSTEM_LOBS.LOB_IDS VALUES(?, ?, ?, ?) (1,49,0,40)
 2012-11-29 10:40:40.250 1 COMMIT 
 2012-11-29 10:40:40.265 1 CALL SYSTEM_LOBS.ALLOC_BLOCKS(?, ?, ?) (1,0,1)
 2012-11-29 10:40:40.265 1 COMMIT 
</pre>
</div>
</div>
<br class="example-break">
<a name="N14B47" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE GC</strong></span>
</p>
<p>
<span class="emphasis"><em>set database gc statement</em></span>
</p>
<p>
<code class="literal">&lt;set database gc statement&gt; ::= SET DATABASE GC
      &lt;unsigned integer literal&gt;</code>
</p>
<p>An optional property which forces calls to <code class="literal">System.gc()
      </code>after the specified number of row operations. The default
      value for this property is 0, which means no System.gc() calls. Usual
      values for this property range from 10000 depending on the system and
      the memory allocation. This property may be useful in some in-process
      deployments, especially with older JVM implementations.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N14B5D" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE TEXT TABLE
      DEFAULTS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database text table defaults
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database text table defaults statement&gt; ::=
      SET DATABASE TEXT TABLE DEFAULTS &lt;character
      literal&gt;</code>
</p>
<p>An optional property to override default text table settings.
      The string literal has the same format as the string used for setting
      the data source of a text table, but without the file name. See the
      <a class="link" href="texttables-chapt.html" title="Chapter&nbsp;5.&nbsp;Text Tables">Text Tables</a>
      chapter.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N14B74" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE TRANSACTION
      CONTROL</strong></span>
</p>
<p>
<span class="emphasis"><em>set database transaction control
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database transaction control statement&gt; ::=
      SET DATABASE TRANSACTION CONTROL { LOCKS | MVLOCKS | MVCC
      }</code>
</p>
<p>Set the concurrency control system for the database. It can be
      issued only when all sessions have been committed or rolled back. This
      command and its modes is discussed in the <a class="link" href="sessions-chapt.html" title="Chapter&nbsp;3.&nbsp;Sessions and Transactions">Sessions and Transactions</a> chapter.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.tx</code>.</p>
<a name="N14B90" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE TRANSACTION ROLLBACK ON
      CONFLICT</strong></span>
</p>
<p>
<span class="emphasis"><em>set database transaction rollback on conflict
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database transaction rollback on conflict
      statement&gt; ::= SET DATABASE TRANSACTION ROLLBACK ON CONFLICT { TRUE |
      FALSE }</code>
</p>
<p>When a transaction deadlock or conflict is about to happen, the
      current transaction is rolled back and an exception is raised. When this
      property is set false, the transaction is not rolled back. Only the
      latest statement that would cause the conflict is undone and an
      exception is raised. The property should not be changed unless the
      application can quickly perform an alternative statement and complete
      the transaction. It is provided for compatibility with other database
      engines which do not roll back the transaction upon deadlock. This
      command is also discussed in the <a class="link" href="sessions-chapt.html" title="Chapter&nbsp;3.&nbsp;Sessions and Transactions">Sessions and Transactions</a> chapter.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.tx_conflict_rollback</code>.</p>
<a name="N14BAC" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE DEFAULT ISOLATION
      LEVEL</strong></span>
</p>
<p>
<span class="emphasis"><em>set database default isolation level
      statement</em></span><code class="literal"> </code>
</p>
<p>
<code class="literal">&lt;set database default isolation level&gt; ::= SET
      DATABASE DEFAULT ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE
      }</code>
</p>
<p>Sets the transaction isolation level for new sessions. The
      default is READ COMMITTED. Each session can also set its isolation
      level.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.tx_level</code>.</p>
<a name="N14BC6" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE UNIQUE
      NAME</strong></span>
</p>
<p>
<span class="emphasis"><em>set database unique name</em></span><code class="literal">
      </code>
</p>
<p>
<code class="literal">&lt;set database unique name statement&gt; ::= SET
      DATABASE UNIQUE NAME &lt;identifier&gt;</code>
</p>
<p>Each HyperSQL catalog (database) has an engine-generated
      internal name. This name is a 16 character long string, beginning with
      HSQLDB and based on the time of creation of the database. The name is
      used for the log events that are sent to external logging frameworks.
      The new name must be exactly 16 characters long with no
      spaces.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
</div>
<div class="section" title="SQL Conformance Settings">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_sql_settings"></a>SQL Conformance Settings</h3>
</div>
</div>
</div>
<p>These statements modify the level of conformance to the SQL
      Standard in different areas. The settings that specify SQL SYNTAX are
      for compatibility with other database engines and are FALSE by default.
      For all the rest of the settings, TRUE means better conformance to the
      Standard (unless the Standard defines the behaviour as implementation
      dependent). The default value of a few of these settings is FALSE, due
      to widespread non-conforming statements that are already in use in user
      applications or statements generated by object relational tools. So long
      as it is practical, it is best to set the non-conforming defaults to
      TRUE in order to improve the quality of the database
      application.</p>
<a name="N14BE1" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL RESTRICT
      EXEC</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql restrict exec
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql restrict exec statement&gt; ::=
      SET DATABASE SQL RESTRICT EXEC { TRUE | FALSE }</code>
</p>
<p>Restricts or allows execution of SQL commands consisting of
      multiple statements in a single string. The property also disallows or
      allows the use of
      <code class="methodname">java.sql.Statement.executeQuery()</code> for any DDL
      or DML statement.</p>
<p>This property is <code class="literal">FALSE</code> by default. SQL
      Standard and JDBC require restriction to a single statement. It is
      advisable to restrict execution.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.restrict_exec</code>.</p>
<a name="N14C01" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL
      SIZE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql size statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql size statement&gt; ::= SET
      DATABASE SQL SIZE { TRUE | FALSE }</code>
</p>
<p>Enable or disable enforcement of column sizes for CHAR and
      VARCHAR columns. The default is TRUE, meaning table definition must
      contain <code class="literal">VARCHAR(n)</code> instead of
      <code class="literal">VARCHAR</code>.</p>
<p>SQL Standard requires enforcement.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.enforce_size</code>.</p>
<a name="N14C21" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL
      NAMES</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql names statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql names statement&gt; ::= SET
      DATABASE SQL NAMES { TRUE | FALSE }</code>
</p>
<p>Enable or disable full enforcement of the rule that prevents
      SQL keywords being used for database object names such as columns and
      tables. The default is <code class="literal">FALSE</code>, meaning
      disabled.</p>
<p>SQL Standard requires enforcement. <span class="emphasis"><em>It is better to
      enable this check, in order to improve the quality and correctness of
      SQL statements.</em></span>
</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.enforce_names</code>.</p>
<a name="N14C40" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL REGULAR
      NAMES</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql regular names
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql regular names statement&gt; ::=
      SET DATABASE SQL REGULAR NAMES { TRUE | FALSE }</code>
</p>
<p>Enable or disable use of the underscore character at the
      beginning, or the dollar character anywhere in database object names
      such as columns and tables. The default is <code class="literal">TRUE</code>,
      meaning disabled.</p>
<p>SQL Standard does not allow the underscore character at the
      start of names, and does not allow the dollar character anywhere in a
      name. This setting can be changed for compatibility with existing
      database or for porting databases which include names that do not
      conform to the Standard.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.regular_names</code>.</p>
<a name="N14C5D" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL
      REFERENCES</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql references
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql references statement&gt; ::= SET
      DATABASE SQL REFERENCES { TRUE | FALSE }</code>
</p>
<p>This command can enable or disable full enforcement of the rule
      that prevents ambiguous column references in SQL statements (usually
      SELECT statements). A column reference is ambiguous when it is not
      qualified by a table name or table alias and can refer to more than one
      column in a JOIN list.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>SQL Standard requires enforcement. <span class="emphasis"><em>It is better to
      enable this check, in order to improve the quality and correctness of
      SQL statements.</em></span> When false, the first matching table is used
      to resolve the column reference.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.enforce_refs</code>.</p>
<a name="N14C7F" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL
      TYPES</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql types statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql types statement&gt; ::= SET
      DATABASE SQL TYPES { TRUE | FALSE }</code>
</p>
<p>This command can enable or disable full enforcement of the
      rules that prevents illegal type conversions and parameters or nulls
      without type in SQL statements (usually SELECT statements). For example
      an INTEGER column or a DATE column cannot be compared to a character
      string or searched with a LIKE expression when the property is
      <code class="literal">TRUE</code>.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>SQL Standard requires enforcement. <span class="emphasis"><em>It is better to
      enable this check, in order to improve the quality and correctness of
      SQL statements.</em></span>
</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.enforce_type</code>.</p>
<a name="N14CA3" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL TDC
      DELETE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql tdc delete
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql tdc delete statement&gt; ::= SET
      DATABASE SQL TDC DELETE { TRUE | FALSE }</code>
</p>
<p>This command can enable or disable full enforcement of the SQL
      Standard rules that prevents triggered data change exceptions caused by
      ON DELETE CASCADE clauses of foreign key constraint.</p>
<p>When there are multiple constraints, a row may be updated by
      one constraint and deleted by another constraint in the same operation.
      This is not allowed by default. Changing this to false allows such
      violations of the Standard to pass without an exception.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>SQL Standard requires enforcement, therefore this property
      shouldn't be changed unless an application written for a non-conforming
      RDBMS needs it.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.enforce_tdc_delete</code>.</p>
<a name="N14CC4" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL TDC
      UPDATE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql tdc update
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql tdc update statement&gt; ::= SET
      DATABASE SQL TDC UPDATE { TRUE | FALSE }</code>
</p>
<p>This command can enable or disable full enforcement of the SQL
      Standard rules that prevents triggered data change exceptions caused by
      multiple ON UPDATE or ON DELETE SET clauses of foreign key constraint.
      When there are multiple constraints, a field in a row may be updated by
      two constraints to different values in the same operation. This is not
      allowed by default. Changing this to <code class="literal">FALSE</code> allows
      such violations of the Standard to pass without an exception.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>SQL Standard requires enforcement, therefore this property
      shouldn't be changed unless an application written for a non-conforming
      RDBMS needs it.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.enforce_tdc_update</code>.</p>
<a name="N14CE6" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL TRANSLATE TTI
      TYPES</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql translate tti types
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql translate tti types statement&gt;
      ::= SET DATABASE SQL TRANSLATE TTI TYPES { TRUE | FALSE
      }</code>
</p>
<p>The JDBC Specification up to version 4.1 does not support some
      SQL Standard built-in types, therefore these types must be translated to
      a supported type when accessed through JDBC ResultSet and
      PreparedStatement methods.</p>
<p>If the property is true, the TIME / TIMESTAMP WITH TIME ZONE
      types and INTERVAL types are represented in JDBC methods of
      <code class="classname">ResultSetMetaData</code> and
      <code class="classname">DatabaseMetaData</code> as JDBC datetime types without
      time zone and the VARCHAR type respectively. The original type names are
      preserved.</p>
<p>The property is <code class="literal">TRUE</code> by default. If set to
      <code class="literal">FALSE</code>, the type codes for WITH TIME ZONE types will
      be SQL type codes as opposed to JDBC type codes.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">jdbc.translate_tti_types</code>.</p>
<a name="N14D0E" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL CHARACTER
      LITERAL</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql character
      literal</em></span>
</p>
<p>
<code class="literal">&lt;set database sql character literal statement&gt;
      ::= SET DATABASE SQL CHARACTER LITERAL { TRUE | FALSE
      }</code>
</p>
<p>When the property is <code class="literal">TRUE</code>, the data type of
      character literal strings is <code class="literal">CHARACTER</code>. When the
      property is <code class="literal">FALSE</code> the data type is
      <code class="literal">VARCHAR</code>.</p>
<p>Setting this property <code class="literal">FALSE</code> results in
      strings not padded with spaces in <code class="literal">CASE WHEN</code>
      expressions that have multiple literal alternatives.</p>
<p>SQL Standard requires the <code class="literal">CHARACTER</code>
      type.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.char_literal</code>.</p>
<a name="N14D44" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL CONCAT
      NULLS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql concat nulls
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql concat nulls statement&gt; ::=
      SET DATABASE SQL CONCAT NULLS { TRUE | FALSE }</code>
</p>
<p>When the property is <code class="literal">TRUE</code>, concatenation of
      a null value with a not-null value results in a null value. When the
      property is <code class="literal">FALSE</code> this type of concatenation result
      in the not-null value.</p>
<p>Setting this property <code class="literal">FALSE</code> results in
      concatenation behaviour similar to Oracle or MS SQL Server.</p>
<p>SQL Standard requires a NULL result.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.concat_nulls</code>.</p>
<a name="N14D6E" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL UNIQUE
      NULLS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql unique nulls
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database sql unique nulls statement&gt; ::=
      SET DATABASE SQL UNIQUE NULLS { TRUE | FALSE }</code>
</p>
<p>When the property is <code class="literal">TRUE</code>, with multi-column
      UNIQUE constraints, it is possible to insert multiple rows for which one
      or more of the values for the constraint columns is NULL. When the
      property is <code class="literal">FALSE</code>, if there is any not-null value in
      the columns, then the set of values is compared to the existing rows and
      if there is a match, an exception is thrown. The setting
      <code class="literal">FALSE</code>, makes the behaviour more restrictive. For
      example, inserting (1, null) twice is possible by default, but not
      possible when the property is <code class="literal">FALSE</code>.</p>
<p>Setting this property <code class="literal">FALSE</code> results in
      UNIQUE constraint behaviour similar to Oracle.</p>
<p>SQL Standard requires the default (TRUE) behaviour.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.unique_nulls</code>.</p>
<a name="N14D9E" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL CONVERT
      TRUNCATE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql convert
      truncate</em></span>
</p>
<p>
<code class="literal">&lt;set database sql convert truncate statement&gt;
      ::= SET DATABASE SQL CONVERT TRUNCATE { TRUE | FALSE
      }</code>
</p>
<p>When the property is <code class="literal">TRUE</code>, conversion from a
      floating point value (a DOUBLE value) to an integral type always
      truncates the fractional part. When the property is
      <code class="literal">FALSE</code>, rounding takes place instead of truncation.
      For example, assigning the value 123456E-2 to an integer column will
      result in 1234 by default, but 1235 when the property is
      <code class="literal">FALSE</code>.</p>
<p>Standard SQL considers this behaviour implementation
      dependent.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.convert_trunc</code>.</p>
<a name="N14DC6" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL AVG
      SCALE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql avg scale</em></span>
</p>
<p>
<code class="literal">&lt;set database sql avg scale&gt; ::= SET DATABASE
      SQL AVG SCALE &lt;numeric value&gt;</code>
</p>
<p>By default, the result of division and the AVG and MEDIAN
      aggregate functions has the same type as the aggregated type of the
      values. This includes the scale. The scale specified with this property
      is used if it is larger than the scale of the operation. For example,
      the average of 5 and 10 is 7 by default, but 7.50 if the scale is
      specified as 2. The result of 7/3 is 2 by default but 2.33 if the scale
      is specified as 2.</p>
<p>Standard SQL considers this behaviour implementation dependent.
      Some databases use a default scale larger than zero.</p>
<p>The property is <code class="literal">0</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.avg_scale</code>.</p>
<a name="N14DE5" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL DOUBLE
      NAN</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql double nan</em></span>
</p>
<p>
<code class="literal">&lt;set database sql double nan&gt; ::= SET DATABASE
      SQL DOUBLE NAN { TRUE | FALSE }</code>
</p>
<p>When the property is <code class="literal">TRUE</code>, division of a
      floating point value (a DOUBLE value) by zero raises an exception. When
      the property is <code class="literal">FALSE</code>, a Java
      <code class="literal">Double.NaN</code>, <code class="literal">POSITIVE_INFINITY</code> or
      <code class="literal">NEGATIVE_INFINITY</code> value is returned.</p>
<p>Standard SQL requires an exception to be raised.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.double_nan</code>.</p>
<a name="N14E13" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL NULLS
      FIRST</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql nulls first</em></span>
</p>
<p>
<code class="literal">&lt;set database sql nulls first&gt; ::= SET DATABASE
      SQL NULLS FIRST { TRUE | FALSE }</code>
</p>
<p>When the property is <code class="literal">TRUE</code>, nulls appear
      before values in result sets with ORDER BY. When set FALSE, nulls appear
      after the values. Some databases, including PostgreSQL, Oracle and MS
      SQL Server, return nulls after the values.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.nulls_first</code>.</p>
<a name="N14E33" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL NULLS
      ORDER</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql nulls order</em></span>
</p>
<p>
<code class="literal">&lt;set database sql nulls order&gt; ::= SET DATABASE
      SQL NULLS ORDER { TRUE | FALSE }</code>
</p>
<p>When NULLS FIRST or NULLS LAST is used explicitly in the ORDER
      BY clause, this property is ignored.</p>
<p>When the property is <code class="literal">TRUE</code>, nulls appear
      according to the value of NULL FIRST property as described
      above.</p>
<p>When set <code class="literal">FALSE</code>, nulls appear according to
      the value of NULLS FIRST property when DESC is not used in the ORDER BY
      clause. But if DESC is used, the position of nulls is reversed. Some
      databases, including MySQL and Oracle, return nulls in this manner when
      DESC is used in ORDER BY.</p>
<p>The property is <code class="literal">TRUE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.nulls_order</code>.</p>
<a name="N14E5A" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL
      IGNORECASE</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql ignorecase</em></span>
</p>
<p>
<code class="literal">&lt;set database sql ignorecase&gt; ::= SET DATABASE
      SQL IGNORECASE { TRUE | FALSE }</code>
</p>
<p>This property is <code class="literal">FALSE</code> by default and should
      only be used in special circumstances where compatibility with a
      different database is required.</p>
<p>When the property is <code class="literal">TRUE</code>, all declarations
      of <code class="literal">VARCHAR</code> columns in tables or other database
      objects are converted to <code class="literal">VARCHAR_IGNORECASE</code>. This has
      a global effect on the database, unlike the <code class="literal">SET
      IGNORECASE</code> statement which applies only to the current
      session.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.ignore_case</code>.</p>
<a name="N14E88" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL LIVE
      OBJECT</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql live object</em></span>
</p>
<p>
<code class="literal">&lt;set database sql live object&gt; ::= SET DATABASE
      SQL LIVE OBJECT { TRUE | FALSE }</code>
</p>
<p>This property is <code class="literal">FALSE</code> by default and can
      only be used in <code class="literal">mem:</code> databases.</p>
<p>When the property is <code class="literal">FALSE</code>, all java objects
      stored in a column of type <code class="literal">OTHER</code> are serialized. When
      the property is <code class="literal">FALSE</code>, objects are not serialized at
      all.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.live_object</code>.</p>
<a name="N14EAF" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL SYS INDEX
      NAMES</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql sys index names</em></span>
</p>
<p>
<code class="literal">&lt;set database sql sys table names statement&gt; ::=
      SET DATABASE SQL SYS INDEX NAMES { TRUE | FALSE }</code>
</p>
<p>This property, when set TRUE, changes the naming method for
      system generated indexes that are used to back constraints. By default,
      the names of those indexes are generated as strings with SYS_ prefixes.
      When the property is set TRUE, the names will be the same as the
      constraint names.</p>
<p>Changing the property does not affect the names of indexes for
      tha constraints that have already been defined. After a restart of the
      database all system-generated indexes are named according to the setting
      for this property.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.sys_index_names</code>.</p>
<a name="N14ECE" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL SYNTAX
      DB2</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql syntax DB2</em></span>
</p>
<p>
<code class="literal">&lt;set database sql syntax DB2 statement&gt; ::= SET
      DATABASE SQL SYNTAX DB2 { TRUE | FALSE }</code>
</p>
<p>This property, when set TRUE, enables support for some elements
      of DB2 syntax. Single-row SELECT statements (<code class="literal">SELECT
      &lt;expression list&gt;</code> without the FROM clause) are supported
      and treated as the SQL Standard equivalent, <code class="literal">VALUES
      &lt;expression list&gt;</code>. The DUAL table is supported, as well
      as the ROWNUM pseudo-column. BINARY type definitions such as VARCHAR(L)
      FOR BIT DATA are supported. Empty DEFAULT clauses in column definitions
      are supported.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.syntax_db2</code>.</p>
<a name="N14EF1" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL SYNTAX
      MSS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql syntax MSS</em></span>
</p>
<p>
<code class="literal">&lt;set database sql syntax MSS statement&gt; ::= SET
      DATABASE SQL SYNTAX MSS { TRUE | FALSE }</code>
</p>
<p>This property, when set TRUE, enables support for some elements
      of SQLServer syntax. Single-row SELECT statements (<code class="literal">SELECT
      &lt;expression list&gt;</code> without the FROM clause) are supported
      and treated as the SQL Standard equivalent, <code class="literal">VALUES
      &lt;expression list&gt;</code>. The parameters of CONVERT() function
      are switched in this mode.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.syntax_mss</code>.</p>
<a name="N14F14" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL SYNTAX
      MYS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql syntax MYS</em></span>
</p>
<p>
<code class="literal">&lt;set database sql syntax MYS statement&gt; ::= SET
      DATABASE SQL SYNTAX MYS { TRUE | FALSE }</code>
</p>
<p>This property, when set TRUE, enables support for some elements
      of MySQL syntax. The TEXT data type is translated to
      LONGVARCHAR.</p>
<p>In CREATE TABLE statements, [NOT NULL | NULL] can be used
      immediately after the column type name and before the DEFAULT clause.
      AUTO_INCREMENT is translated to the GENERATED BY DEFAULT AS IDENTITY
      clause.</p>
<p>Single-row SELECT statements (<code class="literal">SELECT &lt;expression
      list&gt;</code> without the FROM clause) are supported and treated as
      the SQL Standard equivalent, <code class="literal">VALUES &lt;expression
      list&gt;</code>.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.syntax_mys</code>.</p>
<a name="N14F3B" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL SYNTAX
      ORA</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql syntax ORA</em></span>
</p>
<p>
<code class="literal">&lt;set database sql syntax ORA statement&gt; ::= SET
      DATABASE SQL SYNTAX ORA { TRUE | FALSE }</code>
</p>
<p>This property, when set TRUE, enables support for some elements
      of Oracle syntax. The DUAL table is supported, together with ROWNUM,
      NEXTVAL and CURRVAL syntax and semantics.</p>
<p>The non-standard types are translated to supported standard
      types. BINARY_DOUBLE and BINARY_FLOAT are translated to DOUBLE. LONG RAW
      and RAW are translated to VARBINARY with long or medium length limits.
      LONG and VARCHAR2 are translated to VARCHAR with long or medium length
      limits. NUMBER is translated to DECIMAL. Some extra type conversions and
      no-arg functions are also allowed in this mode.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.syntax_ora</code>.</p>
<a name="N14F5A" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE SQL SYNTAX
      PGS</strong></span>
</p>
<p>
<span class="emphasis"><em>set database sql syntax PGS</em></span>
</p>
<p>
<code class="literal">&lt;set database sql syntax PGS statement&gt; ::= SET
      DATABASE SQL SYNTAX PGS { TRUE | FALSE }</code>
</p>
<p>This property, when set TRUE, enables support for some elements
      of PosgtreSQL syntax. The TEXT data type is translated to LONGVARCHAR,
      while the SERIAL data types is translated to BIGINT together with
      GENERATED BY DEFAULT AS IDENTITY.</p>
<p>Single-row SELECT statements (<code class="literal">SELECT &lt;expression
      list&gt;</code> without the FROM clause) are supported and treated as
      the SQL Standard equivalent, <code class="literal">VALUES &lt;expression
      list&gt;</code>.</p>
<p>The functions <code class="literal">NEXTVAL(&lt;sequence name
      string&gt;)</code>, <code class="literal">CURRVAL(&lt;sequence name
      string&gt;)</code> and <code class="literal">LASTVAL()</code> are supported in
      this compatibility mode.</p>
<p>The property is <code class="literal">FALSE</code> by default.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">sql.syntax_pgs</code>.</p>
<a name="N14F8A" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE REFERENTIAL
      INTEGRITY</strong></span>
</p>
<p>
<span class="emphasis"><em>set database referential integrity
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set database referential integrity statement&gt;
      ::= SET DATABASE REFERENTIAL INTEGRITY { TRUE | FALSE
      }</code>
</p>
<p>This command enables or disables the enforcement of referential
      integrity constraints (foreign key constraints), check constraints apart
      from NOT NULL and execution of triggers. By default, all constraints are
      checked.</p>
<p>The only legitimate use of this statement is before importing
      large amounts of external data into tables that have existing FOREIGN
      KEY constraints. After import, the statement must be used again to
      enable constraint enforcement.</p>
<p>If you are not sure the data conforms to the constraints, run
      queries to verify all rows conform to the FOREIGN KEY constraints and
      take appropriate actions for the rows that do not conform.</p>
<p>A query example to return the rows in a foreign key table that
      have no parent is given below:</p>
<div class="example">
<a name="N14FA1"></a>
<p class="title">
<b>Example&nbsp;11.7.&nbsp;Finding foreign key rows with no parents after a bulk
        import</b>
</p>
<div class="example-contents">
<pre class="screen"> SELECT * FROM foreign_key_table LEFT OUTER JOIN primary_key_table 
   ON foreign_key_table.fk_col = primary_key_table.pk_col WHERE primary_key_table.pk_col IS NULL</pre>
</div>
</div>
<br class="example-break">
<p>Only a user with the DBA role can execute this
      statement.</p>
</div>
<div class="section" title="Cache, Persistence and Files Settings">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_cache_persistence"></a>Cache, Persistence and Files Settings</h3>
</div>
</div>
</div>
<p>These statements control the memory and other settings for
      database persistence.</p>
<a name="N14FAE" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES BACKUP INCREMENT
      </strong></span>
</p>
<p>
<span class="emphasis"><em>set files backup increment
      statement</em></span>
</p>
<p>
<code class="literal">&lt;set files backup increment statement&gt; ::= SET
      FILES BACKUP INCREMENT { TRUE | FALSE }</code>
</p>
<p>Older versions of HSQLDB perform a backup of the .data file
      before its contents are modified and the whole .data file is saved in a
      compressed form when a CHECKPOINT or SHUTDOWN is performed. This takes a
      long time when the size of the database exceeds 100 MB or so (on an
      average 2010 computer, you can expect a backup speed of 20MB per second
      or more).</p>
<p>The alternative is backup in increments, just before some part
      of the .data file is modified. In this mode, no backup is performed at
      CHECKPOINT or SHUTDOWN. This mode is preferred for large databases which
      are opened and closed frequently.</p>
<p>The default mode is <code class="literal">TRUE</code>. If the old method
      of backup is preferred, the mode can be set
      <code class="literal">FALSE</code>.</p>
<p>Warning: The old, non-incremental setting, FALSE, shouldn't be
      used at all when the data file is larger than 4GB. If it is used, the
      data file is not fully backed up and can result in corruption. The zip
      compression method is used in this mode and it is limited to 4GB
      size.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.inc_backup</code>.</p>
<a name="N14FD2" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES CACHE ROWS</strong></span>
</p>
<p>
<span class="emphasis"><em>set files cache rows statement</em></span><code class="literal">
      </code>
</p>
<p>
<code class="literal">&lt;set files cache rows statement&gt; ::= SET FILES
      CACHE ROWS &lt;unsigned integer literal&gt;</code>
</p>
<p>Sets the maximum number of rows (of CACHED tables) held in the
      memory cache. The default is 50000 rows.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.cache_rows</code>.</p>
<a name="N14FEC" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES CACHE SIZE</strong></span>
</p>
<p>
<span class="emphasis"><em>set files cache size statement</em></span><code class="literal">
      </code>
</p>
<p>
<code class="literal">&lt;set files cache size statement&gt; ::= SET FILES
      CACHE SIZE &lt;unsigned integer literal&gt;</code>
</p>
<p>Sets maximum amount of data (of CACHED tables) in kilobytes
      held in the memory cache. The default is 10000 kilobytes. Note the
      amount of memory used is larger than this amount, which does not account
      for Java object size overheads.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.cache_size</code>.</p>
<a name="N15006" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES DEFRAG</strong></span>
</p>
<p>
<span class="emphasis"><em>set files defrag statement</em></span>
</p>
<p>
<code class="literal">&lt;set files defrag statement&gt; ::= SET FILES
      DEFRAG &lt;unsigned integer literal&gt;</code>
</p>
<p>Sets the threshold for performing a DEFRAG during a checkpoint.
      The <code class="literal">&lt;unsigned integer literal&gt;</code> is the
      percentage of abandoned space in the <code class="literal">*.data</code> file.
      When a CHECKPOINT is performed either as a result of the
      <code class="literal">.log</code> file reaching the limit set by <code class="literal">SET
      FILES LOG SIZE m</code>, or by the user issuing a CHECKPOINT command,
      the amount of space abandoned since the database was opened is checked
      and if it is larger than the specified percentage, a CHECKPOINT DEFRAG
      is performed instead of a CHECKPOINT. As the DEFRAG operation uses a lot
      of memory and takes a long time with large databases, setting the
      threshold well above zero is suitable for databases that are around than
      500 MB or more.</p>
<p>The default is 0, which indicates no DEFRAG. Useful values are
      between 30 to 60.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.defrag_limit</code>.</p>
<a name="N1502C" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES LOG</strong></span>
</p>
<p>
<span class="emphasis"><em>set files log statement</em></span>
</p>
<p>
<code class="literal">&lt;set files log statement&gt; ::= SET FILES LOG {
      TRUE | FALSE }</code>
</p>
<p>Sets logging of database operations on or off. Turning logging
      off is for special usage, such as temporary cache usage. The default is
      TRUE.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.log_data</code>.</p>
<a name="N15044" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES LOG SIZE</strong></span>
</p>
<p>
<span class="emphasis"><em>set files log size statement</em></span>
</p>
<p>
<code class="literal">&lt;set files log size statement&gt; ::= SET FILES LOG
      SIZE &lt;unsigned integer literal&gt;</code>
</p>
<p>Sets the maximum size in MB of the <code class="literal">*.log</code>
      file to the specified value. The default maximum size is 50 MB. If the
      value is zero, no limit is used for the size of the file. When the size
      of the file reaches this value, a CHECKPOINT is performed and the the
      <code class="literal">*.log</code> file is cleared to size 0.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.log_size</code>.</p>
<a name="N15062" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES NIO</strong></span>
</p>
<p>
<span class="emphasis"><em>set files nio</em></span>
</p>
<p>
<code class="literal">&lt;set files nio statement&gt; ::= SET FILES NIO {
      TRUE | FALSE }</code>
</p>
<p>Sets the access method of the .data file. The default is TRUE
      and uses the Java nio classes to access the file via memory-mapped
      buffers.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.nio_data_file</code>.</p>
<a name="N1507A" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES NIO SIZE</strong></span>
</p>
<p>
<span class="emphasis"><em>set files nio size</em></span>
</p>
<p>
<code class="literal">&lt;set files nio size statement&gt; ::= SET FILES NIO
      SIZE &lt;unsigned integer literal&gt;</code>
</p>
<p>Sets The maximum size of .data file in megabytes that can use
      the nio access method. When the file gets larger than this limit,
      non-nio access methods are used. Values 64, 128, 256, 512, 1024 and
      larger multiples of 512 can be used. The default is 256MB.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.nio_max_size</code>.</p>
<a name="N15092" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES WRITE
      DELAY</strong></span>
</p>
<p>
<span class="emphasis"><em>set files write delay statement</em></span>
</p>
<p>
<code class="literal">&lt;set files write delay statement&gt; ::= SET FILES
      WRITE DELAY {{ TRUE | FALSE } | &lt;seconds value&gt; | &lt;milliseconds
      value&gt; MILLIS}</code>
</p>
<p>Set the WRITE DELAY property of the database. The WRITE DELAY
      controls the frequency of file sync for the log file. When WRITE_DELAY
      is set to FALSE or 0, the sync takes place immediately at each COMMIT.
      WRITE DELAY TRUE performs the sync once every 0.5 seconds (which is the
      default). A numeric value can be specified instead.</p>
<p>The purpose of this command is to control the amount of data loss
      in case of a total system crash. A delay of 1 second means at most the
      data written to disk during the last second before the crash is lost.
      All data written prior to this has been synced and should be
      recoverable.</p>
<p>A write delay of 0 impacts performance in high load situations, as
      the engine has to wait for the file system to catch up.</p>
<p>To avoid this, you can set write delay down to 10
      milliseconds.</p>
<p>Each time the SET FILES WRITE DELAY statement is executed with any
      value, a sync is immediately performed.</p>
<p>Only a user with the DBA role can execute this statement.</p>
<p>This is equivalent to the connection properties
      <code class="literal">hsqldb.write_delay</code> and
      <code class="literal">hsqldb.write_delay_millis</code>.</p>
<a name="N150B5" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES SCALE</strong></span>
</p>
<p>
<span class="emphasis"><em>set files scale</em></span>
</p>
<p>
<code class="literal">&lt;set files scale statement&gt; ::= SET FILES SCALE
      &lt;scale value&gt;</code>
</p>
<p>Changes the scale factor for the .data file. The default scale
      is 32 and allows 64GB of data storage capacity. The scale can be
      increased in order to increase the maximum data storage capacity. The
      scale values 8, 16, 32, 64, 128, 256, 512, 1024 are allowed. Scale value
      1024 allows a maximum capacity of 2 TB.</p>
<p>This command can be used only when there is no data in CACHED
      tables. This is equivalent to the connection property
      <code class="literal">hsqldb.cache_file_scale</code>.</p>
<p>The scale factor indicates the size of the unit of storage of
      data in bytes. For example, with a scale factor of 128, a row containing
      a small amount of data will use 128 bytes. Larger rows may use multiple
      units of 128 bytes.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.cache_file_scale</code>.</p>
<a name="N150D4" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES LOB SCALE</strong></span>
</p>
<p>
<span class="emphasis"><em>set files lob scale</em></span>
</p>
<p>
<code class="literal">&lt;set files lob scale statement&gt; ::= SET FILES
      LOB SCALE &lt;scale value&gt;</code>
</p>
<p>Changes the scale factor for the .lobs file. The scale is
      interpreted in kilobytes. The default scale is 32 and allows 64TB of lob
      data storage capacity. The scale can be reduced in order to improve
      storage efficiency. If the lobs are a lot smaller than 32 kilobytes,
      reducing the scale will reduce wasted space. The scale values 1, 2, 4,
      8, 16, 32 are allowed. For example if the average size of lobs is 4
      kilobytes, the default scale of 32 will result in 28KB wasted space for
      each lob. Reducing the lob scale to 2 will result in average 1KB wasted
      space for each lob.</p>
<p>This command can be used only when there is no lob in the
      database.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.lob_file_scale</code>.</p>
<a name="N150EE" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES LOB
      COMPRESSED</strong></span>
</p>
<p>
<span class="emphasis"><em>set files lob compressed</em></span>
</p>
<p>
<code class="literal">&lt;set files lob compressed statement&gt; ::= SET
      FILES LOB COMPRESSED { TRUE | FALSE }</code>
</p>
<p>By default, lobs are not compressed for storage. When this
      setting is <code class="literal">TRUE</code>, all BLOB and CLOB values stored in
      the database are compressed. Compression reduces the storage size but
      increases the access time.</p>
<p>This command can be used only when there is no lob in the
      database.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>This is equivalent to the connection property
      <code class="literal">hsqldb.lob_compressed</code>.</p>
<a name="N1510B" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES SCRIPT
      FORMAT</strong></span>
</p>
<p>
<span class="emphasis"><em>set files script format</em></span>
</p>
<p>
<code class="literal">&lt;set files script format statement&gt; ::= SET
      FILES SCRIPT FORMAT { TEXT | COMPRESSED }</code>
</p>
<p>Changes the compression setting for database scripts. The
      default is text. Using COMPRESSED results in the storage of the .script
      file in gzip compressed form. Using this command causes a
      CHECKPOINT.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N1511E" class="indexterm"></a>
<p>
<span class="bold"><strong>SET FILES SPACE</strong></span>
</p>
<p>
<span class="emphasis"><em>set files space</em></span>
</p>
<p>
<code class="literal">&lt;set files space statement&gt; ::= SET FILES SPACE
      TRUE</code>
</p>
<p>Enables use of table spaces for CACHED tables. Each table is
      allocated space in blocks. The size of each block in mega bytes is equal
      to the data file scale divided by 16. The default data file scale is 32
      so the default size of each block is 2 MB. See the SET TABLE NEW SPACE
      statement below.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N15131" class="indexterm"></a>
<p>
<span class="bold"><strong>SET TABLE NEW SPACE</strong></span>
</p>
<p>
<span class="emphasis"><em>set table new space</em></span>
</p>
<p>
<code class="literal">&lt;set table new space statement&gt; ::= SET TABLE
      &lt;table name&gt; NEW SPACE</code>
</p>
<p>Sets the named table to use it's own space blocks within the
      .data file. Use of table spaces should be enabled with the SET FILES
      SPACE statement above, before this statement is executed.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<a name="N15144" class="indexterm"></a>
<p>
<span class="bold"><strong>SET TABLE TYPE</strong></span>
</p>
<p>
<span class="emphasis"><em>set table type</em></span>
</p>
<p>
<code class="literal">&lt;set table type statement&gt; ::= SET TABLE
      &lt;table name&gt; TYPE { MEMORY | CACHED }</code>
</p>
<p>Changes the storage type of an existing table between CACHED
      and MEMORY types.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
</div>
<div class="section" title="Authentication Settings">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mtc_authntication_settings"></a>Authentication Settings</h3>
</div>
</div>
</div>
<p>Two settings are available for authentication control.</p>
<p>When the default password authentication is used, the passwords
      can be checked for complexity according to administrative rules</p>
<a name="N1515F" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE PASSWORD CHECK
      FUNCTION</strong></span>
</p>
<p>
<span class="emphasis"><em>set database password check
      function</em></span>
</p>
<p>
<code class="literal">&lt;set database password check function statement&gt;
      ::= SET DATABASE PASSWORD CHECK FUNCTION { &lt;routine body&gt; | NONE
      }</code>
</p>
<p>The routine body is the body of a function that has a VARCHAR
      parameter and returns a BOOLEAN. This function checks the
      <code class="literal">PASSWORD</code> submitted as parameter and returns TRUE if
      it conforms to complexity checks, or FALSE, if it does not.</p>
<p>The <code class="literal">&lt;routine body&gt;</code> can be an SQL block
      or an external Java function reference. This is covered in the <a class="link" href="sqlroutines-chapt.html" title="Chapter&nbsp;8.&nbsp;SQL-Invoked Routines">SQL-Invoked Routines</a>
      chapter</p>
<p>To disable this mechanism, the token <code class="literal">NONE</code>
      can be specified instead of the <code class="literal">&lt;routine
      body&gt;</code>.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<p>In the examples below, an SQL function and a Java function are
      used.</p>
<pre class="programlisting"> SET DATABASE PASSWORD CHECK FUNCTION
   BEGIN ATOMIC
     IF CHAR_LENGTH(PASSWORD) &gt; 6 THEN
       RETURN TRUE;
     ELSE 
       RETURN FALSE;
     END IF;
   END

 SET DATABASE PASSWORD CHECK FUNCTION EXTERNAL NAME 'CLASSPATH:org.anorg.access.AccessClass.accessMethod'

 // the Java method is defined like this
 public static boolean accessMethod(String param) {
     return param != null &amp;&amp; param.length &gt; 6;
 }
</pre>
<p>It is possible to replace the default password authentication
      completely with a function that uses external authentication servers,
      such as LDAP. This function is called each time a user connects to the
      database.</p>
<a name="N1518C" class="indexterm"></a>
<p>
<span class="bold"><strong>SET DATABASE AUTHENTICATION
      FUNCTION</strong></span>
</p>
<p>
<span class="emphasis"><em>set database authentication
      function</em></span>
</p>
<p>
<code class="literal">&lt;set database authentication function statement&gt;
      ::= SET DATABASE AUTHENTICATION FUNCTION { &lt;external body
      reference&gt; | NONE }</code>
</p>
<p>The routine body is an external Java function reference. This
      function has three String parameters. The first parameter is the unique
      name of the database, the second parameter the user name, and the third
      parameter the password.</p>
<p>External authentication can be used in two different patterns.
      In the first pattern, user names must be stored in the database. In the
      second pattern, user names shouldn't be stored in the database and any
      names that are stored in the database are ignored.</p>
<p>In both patterns, the username and password are checked by the
      authentication function. If the function throws a runtime exception then
      authentication fails.</p>
<p>In the first pattern, the function always returns null if
      authentication is successful.</p>
<p>In the second pattern, the function returns a list of role
      names that have been granted to the user. These roles must match the
      ROLE objects that have been defined in the database.</p>
<p>The Java function should return an instance of
      org.hsqldb.jdbc.JDBCArrayBasic constructed with a String[] argument that
      contains the role names.</p>
<p>Only a user with the DBA role can execute this
      statement.</p>
<pre class="programlisting"> SET DATABASE AUTHENTICATION FUNCTION EXTERNAL NAME 'CLASSPATH:org.anorg.access.AccessClass.accessExernalMethod'

 // the Java method is defined like this
 public static java.sql.Array accessExternalMethod(String database, String user, String password) {
     if (externalCheck(database, user, password) {
         return null;
     }
     throw new RuntimeException("failed to authenticate");
 }
</pre>
</div>
</div>
</div>
<HR xmlns:xi="http://www.w3.org/2001/XInclude">
<P xmlns:xi="http://www.w3.org/2001/XInclude" class="svnrev">$Revision: 5675 $</P>
<div class="navfooter">
<hr>
<table summary="Navigation footer" width="100%">
<tr>
<td align="left" width="40%"><a accesskey="p" href="builtinfunctions-chapt.html"><img src="../images/db/prev.png" alt="Prev"></a>&nbsp;</td><td align="center" width="20%">&nbsp;</td><td align="right" width="40%">&nbsp;<a accesskey="n" href="compatibility-chapt.html"><img src="../images/db/next.png" alt="Next"></a></td>
</tr>
<tr>
<td valign="top" align="left" width="40%">Chapter&nbsp;10.&nbsp;Built In Functions&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html"><img src="../images/db/home.png" alt="Home"></a></td><td valign="top" align="right" width="40%">&nbsp;Chapter&nbsp;12.&nbsp;Compatibility With Other DBMS</td>
</tr>
</table>
</div>
</body>
</html>