MS SQL Server 行 GUID 列

发布于 2024-10-07 07:00:12 字数 319 浏览 0 评论 0原文

我很抱歉问了一个看起来很累的问题,但我读过的论坛回复或文档似乎都没有提供足够的答案。

MS SQL Server 2008 中的Row GUID Column 属性的用途是什么?

让我进一步阐述这一点。我已经看到“不要使用GUID作为PK”重复作为这个问题的答案,这似乎与我完全无关。如果我设置 Row GUID Column 是否会强制该 GUID 列为主键或其他内容?

重新表述我原来的问题:如果我的表中有一个 GUID 列在索引中不发挥任何作用,我是否可以通过将该 GUID 列设置为行 GUID 列来获得任何好处?

I apologize for asking what seems like a tired question, but no forum response or documentation I've read seems to provide an adequate answer.

What is the purpose of the Row GUID Column property in MS SQL Server 2008?

Let me extend on that. I've seen "Don't use GUID as the PK" repeated as the answer for this question, which seems to be completely unrelated to me. If I set Row GUID Column is it forcing that GUID column to be the primary key or something?

To rephrase my original question: If I have a GUID column in my table that does not play any role in indexing, do I stand to gain anything from setting that GUID column as the Row GUID Column?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

氛圍 2024-10-14 07:00:12

它使您能够使用 $ROWGUID 变量而不是列名。
它主要用于合并复制。
它不会强制 PK 的 GUID 列,您只能显式声明 PK。
您最后一个问题的答案是否定的,除非您计划实施合并复制。

It enables you to use the $ROWGUID variable instead of the column name.
It's used mostly for merge replication.
It doesn't force the GUID column for PK, you can only declare PKs explicitly.
The answer to your last question is no, unless you plan on implementing Merge Replication.

灯角 2024-10-14 07:00:12

ROWGUIDCOLUMN 主要用于需要将多个卫星数据库表的内容组合到一个中央数据库中的复制场景。

将 ROWGUIDCOLUMN 添加到正在复制的表中可确保复制引擎可以使用 ROWGUIDCOLUMN 字段来区分具有相同主键值的记录。

由于此功能主要用于确保顺利复制,因此您应避免使用此列作为主键。您的主键应该是一个逻辑业务实体,该实体在您的控制之下,并且不会影响您选择的数据库引擎的特定功能的操作特征。

The ROWGUIDCOLUMN is used primarily in replication scenarios where you need to combine the contents of several satelite databases' tables into one central DB.

Adding a ROWGUIDCOLUMN to the tables being replicated ensures that the replication engine can use the ROWGUIDCOLUMN field to differentiate between records with the same primary key values.

Because this is a feature primarily used to ensure smooth replication, you should avoid using this column as your primary key. Your primary key should be a logical business entity that is under your control and which doesn't affect the operational characteristics of specific features of your chosen DB engine.

落叶缤纷 2024-10-14 07:00:12

RowGUID 列用于复制。它允许复制引擎正确合并。启用复制后,此列将添加到尚无 RowGUID 列的表中。

除非您计划实施复制,否则您不会通过使用它获得任何好处。它相当于将 newsequentialid() 设置为列的默认值。

RowGUID column is used for replication. It allows the replication engine to merge correctly. When replication is enabled this column will be added to tables that do not already have a RowGUID column.

You will not gain anything by using it unless you are planning to implement replication. It is equivalent to setting newsequentialid() as the default value for a column.

泪是无色的血 2024-10-14 07:00:12

它并不强制它成为主键,该属性只是确定该字段是否会自动更新。如果要在应用程序中创建 GUID 并将其发送进来,请将此属性设置为 false,否则将其设置为 true 并让数据库自动创建它。如果字段是聚集索引,请确保默认值为 NEWSEQUENTIALID()。

It's not forcing it to be the primary key, the property merely determines if the field will be automatically updated. IF you want to create the GUID in the application and send it in, set this property to false, otherwise set it to true and let the database create it automatically. If the field is the clustered index make sure the default value is NEWSEQUENTIALID().

甜中书 2024-10-14 07:00:12

不,它不会强迫它作为PK。这确实意味着您无法创建第二个唯一标识符并将其指定为行 GUID 列

No it doesn't force it as the PK. It does mean you can't create a second uniqueidentifier and specify that as the Row GUID Column

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文