What does the N in varchar(N) refer to when describing a field in a database. Is it the number of characters or bytes. Also, one is using UTF-8, a character may use more than one byte.
From stackoverflow
-
It's the maximum number of characters.
nvarchar(1000)= max 1000 unicode chars. -
- nr of characters
-
varcharcannot hold Unicode characters, soninvarchar(n)means both number of characters and number of bytes. In case ofnvarchar(n)thenmeans the number of Unicode characters, with storage size of two timesnbytes.If you query
information_schema.columns, there will be, among others, two columns of particular interest:CHARACTER_MAXIMUM_LENGTHandCHARACTER_OCTET_LENGTH. The former holds the number of characters, and the latter contains the number of bytes.
0 comments:
Post a Comment