1

假设我有以下内容table,由Eclipselink.

CREATE TABLE "ACCOUNT" ("ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "DTYPE" VARCHAR(31), "EMAIL" VARCHAR(255));

接下来我将从一个文件中批量导入,其中包含:

1,"admin_","myemail@domain.com"
2,"user_","anotheremail@domain.com"
3,"user_","yetanotherone@domain.com"

导入成功,使用ij toolfromApacheSYSCS_UTIL.SYCS_IMPORT_TABLE().

接下来我将通过JPA2. 这导致:

Caused by: org.apache.derby.client.am.SqlException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL130406103359120' defined on 'ACCOUNT'.

在不运行导入的情况下,我可以创建一个用户就好了。在我看来,导入没有考虑AUTO_INCREMENT表中指定的功能。我不需要更新AUTO_INCREMENT4using ALTER TABLE ACCOUNT AUTO_INCREMENT = 4;,对吗?

4

1 回答 1

1

导入后,执行:

ALTER TABLE ACCOUNT ALTER COLUMN ID RESTART WITH 4

请参阅此链接:http ://db.apache.org/derby/docs/10.9/ref/rrefsqlj81859.html#rrefsqlj81859__rrefsqlj37860

于 2013-04-06T17:38:10.080 回答