替换现有 SQL DB 表中的 PK
现在我有一个数据库,其中 PK 是 int IDENTITY
。最近,去年,我的任务是将这些添加到复制拓扑中。除了 IDENTITY 字段之外,这种方法的效果非常好。
我想探索如何使用 uniqeidentifier
(GUID) 更改或替换它们。
插入新的 PK 列是否可行?
我将其增加到一个big int 会更好吗?
我还应该考虑什么吗?
详细说明为什么我要这样做:
据我了解,当复制遇到 IDENTITY 列时,它会为每个订阅者留出一个 Identity Range(例如 1-1000(默认)),以确保该列具有唯一的 INT。订阅者越多,问题就会变得越大。这导致我们不断收到身份范围检查约束错误。
谢谢
Right now I have a DB where the PK's are int IDENTITY
. I recently, in the last year, was tasked with adding these to a Replication Topology. This has worked out quite well with the exception of the IDENTITY fields.
I want to explore my options for changing or replacing them with a uniqeidentifier
(GUID).
Is it feasible to insert a NEW PK column?
Would I be better of just increasing it to a big int
?
Anything else I should consider?
To elaborate on WHY I want to do do this:
It is my understanding that when Replication encounters an IDENTITY Column it sets aside an Identity Range, say 1-1000(default), for each subscriber to ensure an Unique INT for that column. The more subscribers you have the bigger issue it can become. This leads to the Identity Range Check Constraint errors we keep getting.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实必须删除 INT IDENTITY 列,那么您必须执行以下步骤(或多或少):
我希望这应该能解决问题。
If you really must remove the
INT IDENTITY
column, then you'd have to do these steps (more or less):I hope that should do the trick.