DBDB.io The Encyclopedia of Database Systems · Est. 2017
Database of Databases

Database Entry

H2


H2 ("Hypersonic 2") is an open-source lightweight relational database management system implemented in Java, supporting standard SQL API and JDBC API, as well as PostgreSQL ODBC driver. H2 is characterized by its fast performance and low memory requirement. H2 can be either embedded into a Java application or used as a database server. Both in-memory and disk-based database configurations are available. H2 also has strong security features.[05]

Source Code
https://github.com/h2database/h2database[02]
Developer
Country of Origin
CH
Start Year
2004 [06]
Project Type
Open Source
Written in
Java
Supported Languages
Java
Compatible With
HyperSQL, PostgreSQL
Operating System
All OS with Java VM

Database Entry

H2


H2 ("Hypersonic 2") is an open-source lightweight relational database management system implemented in Java, supporting standard SQL API and JDBC API, as well as PostgreSQL ODBC driver. H2 is characterized by its fast performance and low memory requirement. H2 can be either embedded into a Java application or used as a database server. Both in-memory and disk-based database configurations are available. H2 also has strong security features.[05]

History[06][07]


The development of the H2 database engine started in May 2004, and first published in December 2005. The original developer, Thomas Mueller, also developed the Java database engine Hypersonic SQL (1998 - 2001), which is the origin of HSQLDB. The name H2 stands for Hypersonic 2, but it is built from scratch.

Checkpoints[02]


Two forms of checkpoint creation is supported. "CHECKPOINT" command flushes the data to disk. "CHECKPOINT SYNC" command flushes the data to disk and forces all system buffers be written to the underlying device.

Compression


H2 supports two compression algorithms on objects: LZF and DEFLATE. The default one LZF has faster but lower compression performance, while DEFLATE has higher compression rate.

Concurrency Control[08]


The MVCC mode is enabled by default in version 1.4.x, with the default MVStore storage engine. It is disabled by default when using the default PageStore storage engine in version 1.3.x.

Data Model


H2 is a traditional database management system built based on the relational model of data.

Foreign Keys


Indexes[09][10]


H2 uses Hash Table and AVL-Tree indexes for in-memory tables, and B-Tree indexes for disk-based tables. Indexes are created automatically for primary key and unique constraints. Multi-dimensional indexes is supported in H2. An algorithm called "bit-interleaving", which maps the multi-dimensional key to a single dimensional value on a space-filling curve, is implemented to execute multi-dimension (spatial) range queries efficiently.

Isolation Levels[11]


H2 supports three isolation levels for all data manipulation language (DML) statements: Read Committed, Read Uncommitted and Serializable. The default level is "Read Committed" in most cases. Table level locking is used to make sure all connections only see consistent data. When MVCC is enabled (default setting in version 1.4.x when using the MVStore), instead of table level locking, rows are locked for update and "Read Committed" is used in all cases.

Joins


Logging


Query Compilation


H2 parses the prepared statement and performs local optimization.

Query Execution


Query Interface


SQL

H2 supports standard SQL API.

Storage Architecture


Storage Model


Stored Procedures


In H2, Java functions can be used as stored procedures.

System Architecture[12]


In embedded mode, H2 database can be embedded into an application and runs inside the same JVM using JDBC driver. In the server mode, H2 database is opened remotely using the JDBC driver or ODBC API, and all data is transferred over TCP/IP.

Views


H2 supports read only views and inline views. When using "instead of" triggers, views are updatable.

Citations

12 sources
  1. http://www.h2database.com h2database.com Dead — Check Archive
  2. GitHub - h2database/h2database: H2 is an embeddable RDBMS written in Java. · GitHub github.com
  3. Quickstart h2database.com
  4. H2 Database Engine - Wikipedia wikipedia.org
  5. H2 Database Engine h2database.com
  6. History h2database.com
  7. jOOQ Tuesdays: Thomas Müller Unveils How HSQLDB Evolved into the Popular H2 Database – Java, SQL and jOOQ. jooq.org
  8. Advanced h2database.com
  9. Performance h2database.com
  10. Features h2database.com
  11. Advanced h2database.com
  12. Features h2database.com
Revision #5 Last Updated: