Reasons not to use an auto-incrementing number for a primary key

前端 未结 16 2656
南旧
南旧 2020-12-29 06:02

I\'m currently working on someone else\'s database where the primary keys are generated via a lookup table which contains a list of table names and the last primary key used

16条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 06:36

    Using a unique identifiers would allow you to merge data from two different databases.

    Maybe you have an application that collects data in multiple database and then "syncs" with a master database at various times in the day. You wouldn't have to worry about primary key collisions in this scenario.

    Or, possibly, you might want to know what a record's ID will be before you actually create it.

提交回复
热议问题