负主键 [英] Negative Primary Keys

查看:50
本文介绍了负主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对表使用负主键是否有任何影响(SQL Server 2005 中的身份增量 -1、身份种子 -1)?

Are there any repercussions using Negative Primary Keys for tables (Identity Increment -1, Identity Seed -1 in SQL Server 2005)?

这样做的原因是我们正在创建一个新数据库来替换现有数据库.两个数据库之间有相似的表,我们希望信息的来源"对我们的应用程序是透明的.该方法是创建将两个数据库中的表联合起来的视图.负 PK 确保身份不重叠.

The reason for this is we're creating a new database to replace an existing one. There are similar tables between the two databases and we'd like the "source" of the information to be transparent to our applications. The approach is to create views that unions tables from both databases. Negative PKs ensures the identities don't overlap.

推荐答案

就像其他人所说的,数据库对此没有问题.

Like others have said, the database is fine with this.

但是对于使用 DataSet+DataAdapter 的 .NET 应用程序来说,这将是一个问题,因为它们使用负键作为新记录的临时键.

But it would be a problems for a .NET application that uses DataSet+DataAdapter as they use negative keys as temporaries for new records.

其他数据访问层可能会使用类似的技巧.

Other data-access layers may use similar tricks.

这篇关于负主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆