Are there any good reasons to have a database table without an integer primary key?

前端 未结 11 1820
感动是毒
感动是毒 2021-02-10 00:30

Although I\'m guilty of this crime, it seems to me there can\'t be any good reason for a table to not have an identity field primary key.

Pros: - whether you want to o

11条回答
  •  再見小時候
    2021-02-10 00:57

    Yes, there are good reasons. You can have semantically meaningful true keys, rather than articificial identity keys. Also, it is not a good idea to have a seperate autoincrementing primary key for a Many-Many table. There are some reasons you might want to choose a GUID.

    That being said, I typically use autoincrementing 64bit integers for primary keys.

提交回复
热议问题