DB: To use identity column or not?

前端 未结 4 831
遥遥无期
遥遥无期 2021-02-06 08:33

While designing a table my colleague here says that I should avoid identity column as it is specific to SQL Server and MS Access, But I differ with his views as it makes my codi

4条回答
  •  离开以前
    2021-02-06 09:08

    You can't completely divorce an application from the database vendor. If you do you won't be able to take advantages of whatever features your database provides you.

    I'd say use the identity column. If you move over to Oracle (for example), you can use a Sequence. Hardly a big change.

    I don't know what technology you're using, but one thing that would help is using a tool such as Hibernate or iBATIS (I think they're both available for Java and .NET) which separates you a bit from the database implementation details. Then if you change database vendor you won't need to change application code, just configuration. (In theory, at least!)

提交回复
热议问题