SQL 中的 Unicode 数据类型 [英] Unicode Data Type in SQL

查看:65
本文介绍了SQL 中的 Unicode 数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Microsoft SQL 的新手.我打算在 Microsoft SQL 服务器中存储文本,并且会有特殊的国际字符.是否有特定于 Unicode 的数据类型",或者我最好使用对 Unicode 编号(即 \u0056)的引用来编码我的文本

I'm new to Microsoft SQL. I'm planning to store text in Microsoft SQL server and there will be special international characters. Is there a "Data Type" specific to Unicode or I'm better encoding my text with a reference to the unicode number (i.e. \u0056)

推荐答案

Use Nvarchar/Nchar (MSDN 链接).过去也有 Ntext 数据类型,但现在不推荐使用 Nvarchar.

Use Nvarchar/Nchar (MSDN link). There used to be an Ntext datatype as well, but it's deprecated now in favour of Nvarchar.

列占用的空间是非 unicode 对应项(charvarchar)的两倍.

The columns take up twice as much space over the non-unicode counterparts (char and varchar).

然后当手动"插入它们时,使用 N 表示它是 unicode 文本:

Then when "manually" inserting into them, use N to indicate it's unicode text:

INSERT INTO MyTable(SomeNvarcharColumn) 
VALUES (N'français')

这篇关于SQL 中的 Unicode 数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆