mysql - Which is better: storing string including Unicode characters in NVARCHAR or VARCHAR? -


this question has answer here:

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

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -