mysql - Which is better: storing string including Unicode characters in NVARCHAR or VARCHAR? -
this question has answer here:
- what difference between varchar , nvarchar? 18 answers
i want store string including unicode character.
i know there 2 choices. nvarchar , varchar. nvarchar uses 2 bytes store character; varchar uses 1 byte character.
in terms of storing 2 2-byte unicode character each of them uses 4 bytes. when comes storing 1 1-byte ansi character , 1 2-byte unicode character, nvarchar uses 4 bytes, , varchar uses 3 bytes.
so think using varchar more compact , better method. don't know if understand above right or not because there should advances nvarchar on varchar.
smaller => faster. beware of indexes , type of data present *1. , beware of different datatypes in different types of database servers *2
*1) in mssql: when have index on varchar column , present unicode string, mssql-server not make use of index. same thing happens when present bigint indexed-column containing smallint. if bigint small enough smallint, sql-server not able use index. other way around not have problem (when providing smallint or ansi-code indexed bigint ot nvarchar column).
*2) know every database has different datatypes , varchar not means same everywhere. while mssql has varchar , nvarchar, apache/derby database has varchar , there varchar in unicode.
Comments
Post a Comment