CHAR和VARCHAR之间的区别是什么? [英] WHAT IS THE DIFFERENCE BETWEEN CHAR AND VARCHAR

查看:101
本文介绍了CHAR和VARCHAR之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CHAR和VARCHAR DATA TYPE之间的差异

WHAT IS THE DIFFREENCE BETWEEN CHAR AND VARCHAR DATA TYPE

推荐答案

请查看 http://sqlserverplanet.com/ddl/varchar-vs-char [ ^ ]


快速查看

Char vs Varchar [ ^ ]

SQL Char和Varchar数据类型之间的区别 [ ^ ]


这是命名原因混乱。您可以从名称中预期char数据类型用于存储单个字符。然而,它的作用是为存储字符串分配固定大小。因此,如果您分配了8000个字符存储空间并且只存储了1个字符,则会浪费其他7999个字符。 VarChar的不同之处在于它只分配了所需的字符数。事情变得有趣的是,如果你更新一个VarChar - SQL Server可以分配字符串的新部分,使它与字符串的初始部分不连续。
This is a case where the naming causes confusion. You would expect, from the name, that the char datatype was used to store an individual character. What it does, however, is allocate a fixed size for storing a string. So, if you allocated 8000 character storage and only stored 1 character in it, you would waste the other 7999 characters. VarChar is different in that it only allocates as many characters as are needed. Where things get fun is if you update a VarChar - SQL Server can allocate the new part of the string so that it's non-contiguous with the initial part of the string.


这篇关于CHAR和VARCHAR之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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