Dim*_*tri 2 hibernate jdbc h2 schemaexport
我在H2数据库中的一些sql语句时出错了.那些sql语句来自Hibernate SchemaExport:这是sql语句:
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
Run Code Online (Sandbox Code Playgroud)
例如,该行不会在H2中执行.
错误说: [ERROR] Caused by org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement : CREATE TABLE CONTACTS ( .... <<The same code from above>>
我如何使这个SQL语句在H2中运行.
Dim*_*tri 16
我终于找到了我遇到语法错误的原因.
我实际上运行的是SchemaExport/SchemaUpdateHibernate并且我没有在SQL语句中指定分隔符.
要指定分隔符,请使用该setDelimiter方法.例如,
export.setDelimiter(";");
update.setDelimiter(";");
Run Code Online (Sandbox Code Playgroud)
顺便说一句,要使用SQL语句识别H2中的语法错误,请在语句中找到*它,它将给出错误行.
| 归档时间: |
|
| 查看次数: |
10385 次 |
| 最近记录: |