Is using char as a primary/foreign key a no no?

后端 未结 3 669
清歌不尽
清歌不尽 2021-01-02 08:10

Consider that there is a bunch of tables which link to \"countries\" or \"currencies\" tables.

For making data easier to read I\'d like make CHAR field with country

3条回答
  •  难免孤独
    2021-01-02 09:03

    James Skidmore's link is important to read.

    If you're limiting yourself to country and currency codes (2 and 3 characters, respectively), you may very well be able to get away with declaring the columns char(2) and char(3).

    I would guess that would not be a no-no. If you're using an 8-bit character encoding, you're looking at columns the size of smallint or mediumint, respectively.

提交回复
热议问题