英文:
Generate INSERT script with Sequence Next Value
问题
我目前正在进行数据迁移工作,将数据从本地服务器导出,然后导入到Azure SQL。
我使用“生成脚本”选项,只选择仅数据,数据库中的主表有序列,但在生成INSERT脚本时,它只包括列值。
为了与序列保持一致,我正在寻找一种解决方案,可以生成一个包含NEXT VALUE的INSERT脚本,以在INSERT语句中包含序列本身。
我考虑的另一种方法是导入数据并将序列重置为新的起始值。
欢迎提供任何其他解决方案!
英文:
I am currently working on a data migration where exporting data from on-prem server and importing on the Azure SQL.
I using "Generate Script" with Data Only and database has sequences for the master table but when the INSERT scripts generates it simply includes columns values.
In order to align with the sequences, I am looking for a solution to generate a INSERT script using the NEXT VALUE to accommodate the sequences itself in the INSERT statement.
The other approach I am thinking to import the data and RESET the sequences with new START value.
Any other solution is appreciated!
答案1
得分: 1
建议您导入已分配的序列值的数据,然后在导入后在目标数据库中重置序列:
ALTER SEQUENCE YourSequence
RESTART WITH <在此处指定最大值>;
英文:
I suggest you import the data with the already assigned sequence value and then reset the sequence in the target database after the import:
ALTER SEQUENCE YourSequence
RESTART WITH <specify max value here>;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论