HiLo 还是身份?
只是想获得一些关于主键的意见 - 使用身份/序列号或使用 HiLo 策略(查询高值并增加应用程序本身的低值)会更好吗?
Just wanted to get some opinions on primary keys - would it be better to use identity/sequence numbers or use a HiLo strategy (query for the high value and increment the low value on the app itself)?
如果您使用带有大型表(> 100 万行)的 SQL Server 2005/2008,您可能需要考虑 此,链接到 此。 在某些情况下,scope_identity() 和 @@identity 会出现问题。
当然,围绕当前的实现问题进行设计并不总是最明智的决定。
If you're using SQL Server 2005/2008 with a large table (> 1 million rows), you may want to consider this, which links to this. There's an issue with scope_identity() and @@identity under certain circumstances.
Of course, designing around a current implementation issue isn't always the wisest decision.