Is it ok to use character values for primary keys?

前端 未结 7 1056
悲&欢浪女
悲&欢浪女 2021-01-19 10:54

Is there a performance gain or best practice when it comes to using unique, numeric ID fields in a database table compared to using character-based ones?

For instanc

7条回答
  •  野的像风
    2021-01-19 10:58

    I recommend using ints or bigints for primary keys. Benefits include:

    • This allows for faster joins.
    • Having no semantic meaning in your primary key allows you to change the fields with semantic meaning without affecting relationships to other tables.

    You can always have another column to hold team_code or something for "OAK" and "SD". Also

提交回复
热议问题