H2语句中的语法错误

问题描述:

我在H2数据库中的一些sql语句时出错。 这些SQL语句来从休眠SchemaExport: 这里是SQL语句:H2语句中的语法错误

create table CONTACTS (
    person_id bigint not null, 
    contact_id bigint not null, 
    primary key (person_id, contact_id) 
) 

create table PERSON (
    id bigint generated by default as identity, 
    FNAME varchar(55), 
    NAME varchar(55), 
    primary key (id) 
) 

alter table CONTACTS 
    add constraint UK_r5plahp7wqcsd47hscckyrxgd unique (contact_id) 

alter table CONTACTS 
    add constraint FK_r5plahp7wqcsd47hscckyrxgd 
    foreign key (contact_id) 
    references PERSON 

alter table CONTACTS 
    add constraint FK_90n1kse999lanaepr0v6hcgtv 
    foreign key (person_id) 
    references PERSON 

例如,该行不会在下半年执行。

错误说:[ERROR] Caused by org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement : CREATE TABLE CONTACTS (.... <<The same code from above>>

我怎样才能使H2这个SQL语句运行。

我终于找到了我有语法错误的原因。

我实际上运行一个SchemaExport/SchemaUpdate与Hibernate,我没有在SQL语句中指定分隔符。

要指定分隔符,请使用setDelimiter方法。例如,

export.setDelimiter(";"); 
update.setDelimiter(";"); 

顺便说一句,找出语法错误在H2与SQL语句,发现在声明中*,它会给你错误的路线。

+0

谢谢迪米特里。 '*'线索击中目标) –