varchar or nvarchar

后端 未结 9 1836
走了就别回头了
走了就别回头了 2021-02-19 13:54

I am storing first name and last name with up to 30 characters each. Which is better varchar or nvarchar.

I have read that nvarchar

9条回答
  •  借酒劲吻你
    2021-02-19 14:42

    The nvarchar type is Unicode, so it can handle just about any character that exist in every language on the planet. The characters are stored as UTF-16 or UCS-2 (not sure which, and the differences are subtle), so each character uses two bytes.

    The varchar type uses an 8 bit character set, so it's limited to the 255 characters of the character set that you choose for the field. There are different character set that handles different character groups, so it's usually sufficient for text local to a country or a region.

    If varchar works for what you want to do, you should use that. It's a bit less data, so it's overall slightly faster. If you need to handle a wide variety of characters, use nvarchar.

提交回复
热议问题