What is the difference between varchar and nvarchar?

后端 未结 19 2151
野的像风
野的像风 2020-11-22 04:05

Is it just that nvarchar supports multibyte characters? If that is the case, is there really any point, other than storage concerns, to using varchars

相关标签:
19条回答
  • 2020-11-22 04:35

    Although NVARCHAR stores Unicode, you should consider by the help of collation also you can use VARCHAR and save your data of your local languages.

    Just imagine the following scenario.

    The collation of your DB is Persian and you save a value like 'علی' (Persian writing of Ali) in the VARCHAR(10) datatype. There is no problem and the DBMS only uses three bytes to store it.

    However, if you want to transfer your data to another database and see the correct result your destination database must have the same collation as the target which is Persian in this example.

    If your target collation is different, you see some question marks(?) in the target database.

    Finally, remember if you are using a huge database which is for usage of your local language, I would recommend to use location instead of using too many spaces.

    I believe the design can be different. It depends on the environment you work on.

    0 讨论(0)
提交回复
热议问题