Negative Primary Keys

前端 未结 9 1975
青春惊慌失措
青春惊慌失措 2020-12-10 11:25

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

The reason for this is we\'re creati

相关标签:
9条回答
  • 2020-12-10 11:52

    I think having 2 sources is not the right reason for this approach, while technically allowed. It's not scalable (+1 to Larry Lustig's answer for that).

    I would just create a view or stored procedure that combines both data, by converting the IDs as needed, and would have application to use it instead of direct table reads and unions. This would be scalable by modifying the view/SP later to add one more source.

    0 讨论(0)
  • 2020-12-10 11:57

    If negative numbers turn out to break something, use even numbers for one and odd numbers for the other.

    0 讨论(0)
  • 2020-12-10 11:58

    It is not an issue. Just make sure your Identity column is of a type that allows negative numbers.

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