I’m trying to create h2 DB schema. Here is my sql
JavaScript
x
create extension if not exists uuid_ossp;
create table users
(
user_id uuid default uuid_generate_v4() not null,
name varchar(255),
created_on timestamp,
modified_on timestamp
);
create table product
(
product_id uuid default uuid_generate_v4() not null,
name varchar(25),
created_on timestamp,
modified_on timestamp
);
create table products_users
(
user_id uuid,
product_id uuid
);
And I get an error
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement “CREATE EXTENSION[*] IF NOT EXISTS UUID_OSSP “; expected “OR, FORCE, VIEW, ALIAS, SEQUENCE, USER, TRIGGER, ROLE, SCHEMA, CONSTANT, DOMAIN, TYPE, DATATYPE, AGGREGATE, LINKED, MEMORY, CACHED, LOCAL, GLOBAL, TEMP, TEMPORARY, TABLE, SYNONYM, PRIMARY, UNIQUE, HASH, SPATIAL, INDEX”; SQL statement: create extension if not exists uuid_ossp [42001-199]
Advertisement
Answer
I resolved this by deleting create extension if not exists uuid_ossp;
and adding default random_uuid()
instead of default uuid_generate_v4()
in tables.