varchar 或 nvarchar [英] varchar or nvarchar

查看:26
本文介绍了varchar 或 nvarchar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我存储的名字和姓氏每个最多 30 个字符.varcharnvarchar 哪个更好.

I am storing first name and last name with up to 30 characters each. Which is better varchar or nvarchar.

我读到 nvarchar 占用的空间是 varchar 的两倍,并且 nvarchar 用于国际化.

I have read that nvarchar takes up twice as much space compared to varchar and that nvarchar is used for internationalization.

那么你建议我应该使用什么:nvarcharvarchar ?

So what do you suggest should I use: nvarchar or varchar ?

另外请让我知道两者的表现.两者的性能相同还是性能不同.因为空间不是太大的问题.问题是性能.

Also please let me know about the performance of both. Is performance for both is same or they differ in performance. Because space is not too big issue. Issue is the performance.

推荐答案

基本上,nvarchar 意味着您可以处理大量字母,而不仅仅是普通的英语.从技术上讲,这意味着 unicode 支持,而不仅仅是 ANSI.这意味着双宽字符或大约两倍的空间.现在磁盘空间非常便宜,您不妨从一开始就使用 nvarchar,而不是在产品的生命周期中经历不得不更改的痛苦.

Basically, nvarchar means you can handle lots of alphabets, not just regular English. Technically, it means unicode support, not just ANSI. This means double-width characters or approximately twice the space. These days disk space is so cheap you might as well use nvarchar from the beginning rather than go through the pain of having to change during the life of a product.

如果你确定你只需要支持一种语言,你可以坚持使用 varchar,否则我会选择 nvarchar.

If you're certain you'll only ever need to support one language you could stick with varchar, otherwise I'd go with nvarchar.

此处之前已经在SO上讨论过这一点.

This has been discussed on SO before here.

已如注释中所述,将 ascii 更改为 ANSI.

EDITED: changed ascii to ANSI as noted in comment.

这篇关于varchar 或 nvarchar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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