SQL Server索引 - varchar(100)vs varbinary(100)? [转换数据] [英] SQL Server indexing - varchar(100) vs varbinary(100)? [convert data]

查看:224
本文介绍了SQL Server索引 - varchar(100)vs varbinary(100)? [转换数据]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

varchar(x) varbinary(x)专栏?

我不确定它是否重要。然而,我在网上看到的(Googled - varchar vs varbinary)是 varchar 几乎已经死亡或被推到路边。索引或其他东西更好吗?可能是索引的类型吗?

I wasn't sure it even mattered. However what I see online (Googled - varchar vs varbinary) is that varchar is almost dead or being pushed to the way side. So is this better to index or something? Could it be the type of index?

优秀方案:索引电子邮件地址( [edit] 加密字节数组{varbinary}或等价的字符串{varchar})

Excellent scenario: Indexing email addresses ([edit] encrypted byte array {varbinary} or string equivalent {varchar})

谢谢

似乎 varbinary 上的索引是最糟糕的事情。我读得对吗?

It seems that indexes on varbinary is the worst thing ever. Am I reading this right?

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/35b61bb0-1fa8-4a2f- a9fb-729a1874dcf8 / cluster-index-on-varbinary-column

推荐答案

最好创建一个varchar上的索引比varbinary。 Varbinary适用于blob,但你也可以在varbinary中存储字符串。这些blob与您的实际数据互补。您自己的研究也会得出这样的结论。

It is better to create an index on varchar than varbinary. Varbinary is suitable for blobs but you can store strings in varbinary also. Such blobs are complementary to your actual data. Your own research lead to that conclusion also.

用户可以用各种格式输入电子邮件地址 - abc@xyz.com或Abc@Xyz.com等。在varchar字段中存储/提取此类信息更容易。 Joe Enos绝对正确,二进制比较将区分大小写(比较二进制信息),而varchar将不区分大小写,假设您已经设置了数据库和列排序规则。使用varbinary,您还必须小心填充

An email address can be entered by user in variety of formats - abc@xyz.com or Abc@Xyz.com etc. It is easier to store/extract such information in/from varchar field. Joe Enos is absolutely right that binary comparisons will be case-sensitive (comparing binary info) whereas varchar will be case-insensitive assuming that's how you have set up your DB and column collation. With varbinary, you'll also have to be careful about padding.

Varchar活着且健康。索引varchar(100)时,请尝试使用非聚集索引。我的一般偏好是在大多数情况下使用代理键作为聚集索引。

Varchar is alive and healthy. When you index varchar(100), try to use a non-clustered index. My general preference is to use a surrogate key in most situations as clustered index.

这篇关于SQL Server索引 - varchar(100)vs varbinary(100)? [转换数据]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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