Primary Keys in Oracle and SQL Server

后端 未结 4 1331
别跟我提以往
别跟我提以往 2021-01-21 16:24

What\'s the best practice for handling primary keys using an ORM over Oracle or SQL Server?

Oracle - Should I use a sequence and a trigger or let the OR

4条回答
  •  生来不讨喜
    2021-01-21 16:57

    With either database, I would use a client-generated Guid for the primary key (which would map to uniqueidentifier in SQL Server, or RAW(20) in Oracle). Despite the performance penalty on JOINs when using a Guid foreign key, I tend to work with disconnected clients and replicated databases, so being able to generate unique IDs on the client is a must. Guid IDs also have advantages when working with an ORM, as they simplify your life considerably.

提交回复
热议问题