H2 equivalent to SET IDENTITY_INSERT

若如初见. 提交于 2019-12-25 02:44:55

问题


I'm using H2 to JUnit test a system that will run using MS SQL Server in production.

As part of the latest version I need to make some DDL changes and migrate data from the old structure to the new. And that will involve copying data into a new table that has an identity column.

I'm actually splitting a single table into two. Going forward the new table will have an independent (identity) primary key, but for initialization it needs to have the same value for the primary key as the original table (i.e. on migration it's one-to-one, afterwards it will be one-to-many).

I don't mind having H2 and SQL Server specific code in the system (the DDL is already system specific) as long as the resulting structure is equivalent, so if there is an H2 option or a JDBC trick that will achieve this that'd be fine.

Everything is being run using the Spring JdbcTemplate.

Thanks for any suggestions.

来源:https://stackoverflow.com/questions/33820167/h2-equivalent-to-set-identity-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!