【发布时间】:2018-03-13 23:26:30
【问题描述】:
这是 schema.SQL 的脚本。当它到达脚本的 alter table 部分时显示错误:
DROP TABLE IF EXISTS billing_address;
CREATE TABLE billing_address (
id bigint(20) NOT NULL AUTO_INCREMENT,
billingAddressCity varchar(255),
billingAddressCountry varchar(255),
billingAddressName varchar(255),
billingAddressState varchar(255),
billingAddressStreet1 varchar(255),
billingAddressStreet2 varchar(255),
billingAddressZipCode varchar(255),
order_id bigint (20),
PRIMARY KEY (id)
);
alter table user_role drop constraint if exists FKa68196081fvovjhkek5m97n3y foreign key (role_id) references role (roleid);
alter table user_role add constraint FKa68196081fvovjhkek5m97n3y foreign key (role_id) references role (roleid);
> Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "ALTER TABLE BILLING_ADDRESS DROP CONSTRAINT IF EXISTS FKN9O6NQ40AQJYEBAOFKOLMGV69 FOREIGN[*] KEY (ORDER_ID) REFERENCES USER_ID "; SQL statement:
alter table billing_address drop constraint if exists FKn9o6nq40aqjyebaofkolmgv69 foreign key (order_id) references user_id [42000-196]
【问题讨论】:
-
在到达问题行之前,有很多代码需要滚动浏览。您可能应该编辑掉脚本中不相关的部分,使其成为minimal, complete, verifiable example。我猜这就是这个问题被否决的原因。