Hsqldb User Guide
Total Page:16
File Type:pdf, Size:1020Kb
Hsqldb User Guide The HSQLDB Development GroupEdited by Blaine Simpson and Fred Toussi Hsqldb User Guide by The HSQLDB Development Group, Blaine Simpson, and Fred Toussi Published $Date: 2004/07/18 03:48:05 $ Copyright 2002-2004 HSQLDB Development Group. Permission is granted to distribute this document without any alteration un- der the terms of the HSQLDB license. Table of Contents Introduction ...............................................................................................................x Available formats for this document ....................................................................... x 1. Running and Using Hsqldb ........................................................................................ 1 Introduction ....................................................................................................... 1 Running Tools ....................................................................................................1 Running Hsqldb .................................................................................................. 2 Server Modes .....................................................................................................2 Hsqldb Server ............................................................................................. 3 Hsqldb Web Server ..................................................................................... 3 Hsqldb Servlet ............................................................................................ 3 In-Process (Standalone) Mode ....................................................................... 4 Memory-Only Databases .............................................................................. 5 General .............................................................................................................5 Closing the Database ................................................................................... 5 Using Multiple Databases in One JVM ............................................................ 5 Creating a New Database .............................................................................. 5 Using the Database Engine ................................................................................... 6 Different Types of Tables ............................................................................. 6 Constraints and Indexes ................................................................................ 7 SQL Support ..............................................................................................7 JDBC Support ............................................................................................7 2. SQL Issues .............................................................................................................8 Purpose .............................................................................................................8 SQL Standard Support ......................................................................................... 8 Constraints and Indexes ........................................................................................ 8 Primary Key Constraints ............................................................................... 8 Unique Constraints ...................................................................................... 8 Unique Indexes ........................................................................................... 9 FOREIGN KEYS ........................................................................................ 9 Indexes and Query Speed .............................................................................. 9 Where Condition or Join ............................................................................. 10 Subqueries and Joins .................................................................................. 11 Types and Arithmetic Operations ......................................................................... 11 Integral Types .......................................................................................... 12 Other Numeric Types ................................................................................. 12 Bit and Boolean Types ............................................................................... 13 Storage and Handling of Java Objects ........................................................... 13 Type Size, Precision and Scale .................................................................... 13 Sequences and Identity ....................................................................................... 14 Identity Auto-Increment Columns ................................................................ 14 Sequences ................................................................................................ 14 Issues with Transactions ..................................................................................... 15 New Features and Changes ................................................................................. 15 3. UNIX Quick Start .................................................................................................. 16 Purpose ........................................................................................................... 16 Installation ....................................................................................................... 16 Setting up Database Instance and Server ................................................................ 18 Accessing your Database .................................................................................... 19 Create additional Accounts ................................................................................. 21 Shutdown ........................................................................................................ 22 Running Hsqldb as a System Daemon ................................................................... 22 Portability of hsqldb init script ..................................................................... 22 Init script Setup Procedure .......................................................................... 23 iv Hsqldb User Guide Troubleshooting the Init Script .................................................................... 26 4. Advanced Topics ................................................................................................... 27 Purpose ........................................................................................................... 27 Connections ..................................................................................................... 27 Connection properties ................................................................................ 28 Properties Files ................................................................................................. 29 Server and Web Server Properties ................................................................ 30 Starting a Server from your application ......................................................... 31 Individual Database Properties ..................................................................... 31 JDBC Stream Based Methods .............................................................................. 33 Managing Database Connections .......................................................................... 34 Memory and Disk Use ....................................................................................... 34 Cache Memory Allocation .......................................................................... 35 Upgrading and Managing Databases ..................................................................... 36 Upgrading Using the SCRIPT Command ....................................................... 36 Manual Changes to the .script File ................................................................ 37 Backing Up Databases ............................................................................... 37 5. Text Tables ........................................................................................................... 38 The Implementation ........................................................................................... 38 Definition of Tables ................................................................................... 38 Scope and Reassignment ............................................................................ 39 Null Values in Columns of Text Tables ......................................................... 39 Configuration ........................................................................................... 39 Text File Issues ................................................................................................. 41 Text File Global Properties ................................................................................. 41 Importing from a Text Table file .......................................................................... 42 6. TLS .................................................................................................................... 43 Requirements ................................................................................................... 43 Encrypting your JDBC connection ....................................................................... 43 Client-Side .............................................................................................. 43 Server-Side .............................................................................................