Hypersql User Guide Hypersql Database Engine 2.3.4
Total Page:16
File Type:pdf, Size:1020Kb
HyperSQL User Guide HyperSQL Database Engine 2.3.4 Edited by , Blaine Simpson, and Fred Toussi HyperSQL User Guide: HyperSQL Database Engine 2.3.4 by , Blaine Simpson, and Fred Toussi $Revision: 5631 $ Publication date 2016-05-15 15:57:21-0400 Copyright 2002-2016 Blaine Simpson, Fred Toussi and The HSQL Development Group. Permission is granted to distribute this document without any alteration under the terms of the HSQLDB license. You are not allowed to distribute or display this document on the web in an altered form. Table of Contents Preface ........................................................................................................................................ xiii Available formats for this document ......................................................................................... xiii 1. Running and Using HyperSQL ....................................................................................................... 1 Introduction ............................................................................................................................. 1 The HSQLDB Jar .................................................................................................................... 1 Running Database Access Tools ................................................................................................. 2 A HyperSQL Database .............................................................................................................. 2 In-Process Access to Database Catalogs ....................................................................................... 3 Server Modes .......................................................................................................................... 4 HyperSQL HSQL Server ................................................................................................... 4 HyperSQL HTTP Server ................................................................................................... 5 HyperSQL HTTP Servlet ................................................................................................... 5 Connecting to a Database Server ......................................................................................... 5 Security Considerations ..................................................................................................... 6 Using Multiple Databases .................................................................................................. 6 Accessing the Data ................................................................................................................... 6 Closing the Database ................................................................................................................ 7 Creating a New Database .......................................................................................................... 7 2. SQL Language ............................................................................................................................. 9 Standards Support .................................................................................................................... 9 SQL Data and Tables ............................................................................................................... 9 Temporary Tables ........................................................................................................... 10 Persistent Tables ............................................................................................................ 10 Short Guide to Data Types ....................................................................................................... 11 Data Types and Operations ...................................................................................................... 12 Numeric Types .............................................................................................................. 12 Boolean Type ................................................................................................................ 14 Character String Types .................................................................................................... 14 Binary String Types ........................................................................................................ 15 Bit String Types ............................................................................................................. 16 Lob Data ...................................................................................................................... 17 Storage and Handling of Java Objects ................................................................................ 17 Type Length, Precision and Scale ...................................................................................... 18 Datetime types ....................................................................................................................... 19 Interval Types ........................................................................................................................ 22 Arrays .................................................................................................................................. 25 Array Definition ............................................................................................................. 25 Array Reference ............................................................................................................. 27 Array Operations ............................................................................................................ 27 Indexes and Query Speed ......................................................................................................... 29 Query Processing and Optimisation ........................................................................................... 30 Indexes and Conditions ................................................................................................... 30 Indexes and Operations ................................................................................................... 31 Indexes and ORDER BY, OFFSET and LIMIT .................................................................... 31 3. Sessions and Transactions ............................................................................................................ 33 Overview .............................................................................................................................. 33 Session Attributes and Variables ............................................................................................... 33 Session Attributes ........................................................................................................... 34 Session Variables ........................................................................................................... 34 Session Tables ............................................................................................................... 34 Transactions and Concurrency Control ....................................................................................... 35 iii HyperSQL User Guide Two Phase Locking ........................................................................................................ 35 Two Phase Locking with Snapshot Isolation ........................................................................ 36 Lock Contention in 2PL .................................................................................................. 36 Locks in SQL Routines and Triggers ................................................................................. 36 MVCC ......................................................................................................................... 36 Choosing the Transaction Model ....................................................................................... 37 Schema and Database Change ........................................................................................... 38 Simultaneous Access to Tables ......................................................................................... 38 Viewing Sessions ........................................................................................................... 38 Session and Transaction Control Statements ................................................................................ 39 4. Schemas and Database Objects ...................................................................................................... 46 Overview .............................................................................................................................. 46 Schemas and Schema Objects ................................................................................................... 46 Names and References .................................................................................................... 47 Character Sets ................................................................................................................ 47 Collations ...................................................................................................................... 48 Distinct Types ................................................................................................................ 49 Domains ....................................................................................................................... 49 Number Sequences ........................................................................................................