What data type is recommended for ID columns?

后端 未结 9 1667
既然无缘
既然无缘 2021-02-08 04:35

I realize this question is very likely to have been asked before, but I\'ve searched around a little among questions on StackOverflow, and I didn\'t really find an answer to

9条回答
  •  无人及你
    2021-02-08 05:18

    Popular databases allow for larger autoincrement fields for years now, so it's much less of an issue.

    As for what to use, it's always a choice. One is not clearly better than the other, they have different characteristics and each is good in different scenarios. I have used both over time, and the next schema I work with I'll consider both.

    Pros for GUID:

    • Should be unique across computers.
    • Random, unmemorable goo means people are likely to use this only for its intended purpose of an opaque identifier.

    Pros for autoincrement:

    • Human understandable.
    • Sequential assignment means you can use a clustered index and impact performance.
    • Suitable for data partitioning.

提交回复
热议问题