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.
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.
H2 supports standard SQL API.
H2 supports read only views and inline views. When using "instead of" triggers, views are updatable.
Multi-version Concurrency Control (MVCC)
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.
N-ary Storage Model (Row/Record)
Read Uncommitted Read Committed Serializable
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.
In H2, Java functions can be used as stored procedures.
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.
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.
H2 is a traditional database management system built based on the relational model of data.
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.
H2 parses the prepared statement and performs local optimization.
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.
Eclipse Public License, Mozilla Public License