英文:
SQL Server (2016) Changing INT to BIGINT
问题
当将 INT 列更改为 BIGINT 列时,表中有超过 10 亿行时,是否仍然最佳做法是创建新表,然后迁移数据,或者在现今情况下使用 ALTER COLUMN
一样有效?
不太担心停机时间。
英文:
When changing an INT column to a BIGINT column on a table with over a 1 billion rows, is it still best practice to create a new table and then migrate the data, or is an ALTER COLUMN
just as effective these days?
Not overly worried about downtime.
答案1
得分: 4
是否仍然是最佳实践创建新表然后迁移数据,
这只是在日志空间不足、阻塞过多或失败时回滚时间的情况下的一种权宜之计。所以如果你有足够的时间和资源,只需使用ALTER TABLE命令。
请注意,一旦开始执行ALTER TABLE命令,你就必须让它完成,否则如果取消它,可能需要很长时间来回滚。
批量加载新表可以很容易地中止,因为只需要回滚分配的范围。
英文:
>is it still best practice to create a new table and then migrate the data,
That's just a workaround for running out of log space, or excessive blocking, or rollback time in case of failure. So if you've got plenty of time and resources, just ALTER the table.
Just be aware that once you start the ALTER TABLE you're committed to let it finish or wait a possibly long time for it to roll back if you cancel it.
Bulk loading a new table can be aborted with little cost, as only the extent allocations need to be rolled back.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论