MS SQL Server Row GUID Column

后端 未结 5 1682
春和景丽
春和景丽 2020-12-24 13:34

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 o

相关标签:
5条回答
  • 2020-12-24 13:49

    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.

    0 讨论(0)
  • 2020-12-24 13:50

    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.

    0 讨论(0)
  • 2020-12-24 13:53

    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

    0 讨论(0)
  • 2020-12-24 13:58

    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.

    0 讨论(0)
  • 2020-12-24 14:05

    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().

    0 讨论(0)
提交回复
热议问题