Skip to content

H2 Schema designλ︎

Key concepts and syntax for designing database schema for the H2 database

Auto-increment values in H2 databaseλ︎

The IDENTITY type is used for automatically generating an incrementing 64-bit long integer in H2 database.

CREATE TABLE public.account (
  id IDENTITY NOT NULL PRIMARY KEY ,
  name VARCHAR NOT NULL,
  number VARCHAR NOT NULL,
  sortcode VARCHAR NOT NULL,
  created TIMESTAMP WITH TIME ZONE NOT NULL);

The value for id is automatically generated by H2, so no need to provide a value for id in the SQL statement

INSERT INTO public.account ( id, name, number, sortcode, created)
VALUES ( ? , ? , ? , ? );

Resourcesλ︎