JavaDB:是否可以更改现有表的自动增量偏移量?
是否可以使用 JavaDB 更改预先存在的表上的自动增量偏移量?
我遇到的问题是,插入新记录通常(但并非总是)失败,并出现错误,抱怨使用现有键(我的自动增量列)。 为了填充此数据库,我从另一个数据库 (MySQL) 获取转储,并使用 JavaDB 存储过程将它们全部插入到相应的 JavaDB 表中。 我的理论是,插入这些记录会复制 MySQL 表中的现有 ID。 现在,自动增量功能正在分发现有的 ID。 我认为明确地将偏移量设置为某个较高的数字将允许自动增量再次起作用。
Is it possible to change the auto-increment offset on a pre-existing table with JavaDB?
I'm having a problem where inserting new records usually (but not always) fails with an error complaining about using an existing key (my auto-increment column). To populate this database, I took a dump from another database (MySQL) and used a JavaDB stored procedure to insert them all into the corresponding JavaDB table. My theory is that inserting these records copied the existing IDs from the MySQL table. Now the auto-increment functionality is dishing out existing IDs. I figure explicitly setting the offset to some high number will allow the auto-increment to work again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
即使这不是问题的直接答案:
使用MySQL,您可以
设置自动增量值。
Even if it's not a direct answer to the question:
With MySQL, you can do a
to set the auto increment value.
我不知道如何直接更改偏移量,但我设法通过以下方式解决此问题:
我使用这个SQL语句来改变增量数量:
I don't know how to directly change the offset, but I managed to fix this by:
I used this SQL statement to change the increment amount: