Preview HSQLDB Tutorial (PDF Version)
Total Page:16
File Type:pdf, Size:1020Kb
About the Tutorial HyperSQL Database is a modern relational database manager that conforms closely to the SQL:2011 standard and JDBC 4 specifications. It supports all core features and RDBMS. HSQLDB is used for the development, testing, and deployment of database applications. In this tutorial, we will look closely at HSQLDB, which is one of the best open-source, multi-model, next generation NoSQL product. Audience This tutorial is designed for Software Professionals who are willing to learn HSQL Database in simple and easy steps. It will give you a great understanding on HSQLDB concepts. Prerequisites Before you start practicing the various types of examples given in this tutorial, we assume you are already aware of the concepts of database, especially RDBMS. Disclaimer & Copyright Copyright 2016 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected]. i Table of Contents About the Tutorial .................................................................................................................................... i Audience .................................................................................................................................................. i Prerequisites ............................................................................................................................................ i Disclaimer & Copyright ............................................................................................................................. i Table of Contents .................................................................................................................................... ii 1. HSQLDB – INTRODUCTION .................................................................................................. 1 Features of HSQLDB ................................................................................................................................ 1 Components of HSQLDB .......................................................................................................................... 1 2. HSQLDB – INSTALLATION..................................................................................................... 2 Prerequisites ........................................................................................................................................... 2 HSQLDB Installation ................................................................................................................................ 2 3. HSQLDB – CONNECT ............................................................................................................ 8 4. HSQLDB – DATA TYPES ...................................................................................................... 10 Exact Numeric Data Types ..................................................................................................................... 10 Approximate Numeric Data Types ......................................................................................................... 10 Date and Time Data Types..................................................................................................................... 11 Character Strings Data Types ................................................................................................................. 11 Unicode Character Strings Data Types ................................................................................................... 11 Binary Data Types ................................................................................................................................. 12 Misc Data Types .................................................................................................................................... 12 5. HSQLDB – CREATE TABLE................................................................................................... 13 HSQLDB – JDBC Program ....................................................................................................................... 13 ii 6. HSQLDB – DROP TABLE ...................................................................................................... 15 HSQLDB – JDBC Program ....................................................................................................................... 15 7. HSQLDB – INSERT QUERY .................................................................................................. 17 HSQLDB – JDBC Program ....................................................................................................................... 17 8. HSQLDB – SELECT QUERY .................................................................................................. 20 HSQLDB – JDBC Program ....................................................................................................................... 21 9. HSQLDB – WHERE CLAUSE ................................................................................................ 23 HSQLDB – JDBC Program ....................................................................................................................... 24 10. HSQLDB – UPDATE QUERY ................................................................................................. 26 HSQLDB – JDBC Program ....................................................................................................................... 26 11. HSQLDB – DELETE CLAUSE ................................................................................................. 28 HSQLDB – JDBC Program ....................................................................................................................... 28 12. HSQLDB – LIKE CLAUSE ...................................................................................................... 30 HSQLDB – JDBC Program ....................................................................................................................... 31 13. HSQLDB – SORTING RESULTS ............................................................................................. 33 Example ................................................................................................................................................ 33 HSQLDB – JDBC Program ....................................................................................................................... 34 14. HSQLDB – JOINS ................................................................................................................ 36 JOIN Types ............................................................................................................................................ 37 Inner Join .............................................................................................................................................. 37 Left Join ................................................................................................................................................. 39 Right Join .............................................................................................................................................. 41 Full Join ................................................................................................................................................. 43 Self Join ................................................................................................................................................. 44 iii 15. HSQLDB – NULL VALUES .................................................................................................... 47 HSQLDB – JDBC Program ....................................................................................................................... 49 16. HSQLDB – REGULAR EXPRESSIONS .................................................................................... 51 17. HSQLDB – TRANSACTIONS ................................................................................................. 54 Properties of Transactions .................................................................................................................... 54 Commit, Rollback, and Savepoint .......................................................................................................... 54 Release Savepoint ................................................................................................................................. 59 18. HSQLDB – ALTER COMMAND ............................................................................................ 60 Dropping or Adding a Column ............................................................................................................... 60 Changing a Column Definition or Name ................................................................................................ 61 19. HSQLDB – INDEXES ...........................................................................................................