The CHAR and VARCHAR Types

  The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to store. For example,CHAR(30) can hold up to 30 characters.

  括号中指定宽度。

  The length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value from 0 to 255. WhenCHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled.

  CHAR长度为0-255,固定,取值时尾部空格忽略,除非PAD_CHAR_TO_FULL_LENGTH模式被启用。

  Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

  VARCHAR长度为0-65535,VARCHAR与其它列共享最大长度65535。  

  In contrast to CHARVARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.

  VARCHAR将长度存储在头部,1-2字节。

  

  

参考:https://dev.mysql.com/doc/refman/5.7/en/char.html

The CHAR and VARCHAR Types的更多相关文章

  1. mysql CHAR and VARCHAR 比较

    写在前面 面试的时候突然有一位面试官问,说说CHAR和VARCHAR的区别,懵逼了,想自己平常使用的时候直接把VARCHAR拿来就用,真没注意到其中的不同. 反思,为什么没有注意到他们的不同 对于my ...

  2. SQL中char、varchar、nvarchar、ntext的区别(转载)

    char    char是定长的,也就是当你输入的字符小于你指定的数目时,char(8),你输入的字符小于8时,它会再后面补空值.当你输入的字符大于指定的数时,它会截取超出的字符.nvarchar(n ...

  3. 数据库中char与varchar类型的区别

    在建立数据库表结构的时候,为了给一个String类型的数据定义一个数据库的数据库类型,一般参考的都是char或者varchar,这两种选择有时候让人很纠结,今天想总结一下它们两者的区别,明确一下选择塔 ...

  4. MySQL char与varchar的差异

    字符与字节的区别 一个字符由于所使用的字符集的不同,会并存储在一个或多个字节中,所以一个字符占用多少个字节取决于所使用的字符集 注意:char与varchar后面接的数据大小为存储的字符数,而不是字节 ...

  5. SqlServer -- char与varchar、nchar、N

    一.char与varchar 带var的表示的是:可变长度,会根据实际存储数据的大小动态重新分配存储空间,相对来说节省存储空间. 不带var的表示的是:固定长度,存储3字符也是要占用10个字节的,会自 ...

  6. char、varchar、text和nchar、nvarchar、ntext的区别

    1.CHAR.CHAR存储定长数据很方便,CHAR字段上的索引效率级高,比如定义char(10),那么不论你存储的数据是否达到了10个字节,都要占去10个字节的空间,不足的自动用空格填充,所以在读取的 ...

  7. 答:SQLServer DBA 三十问之一: char、varchar、nvarchar之间的区别(包括用途和空间占用);xml类型查找某个节点的数据有哪些方法,哪个效率高;使用存储 过程和使用T-SQL查询数据有啥不一样;

    http://www.cnblogs.com/fygh/archive/2011/10/18/2216166.html 1. char.varchar.nvarchar之间的区别(包括用途和空间占用) ...

  8. mysql中char,varchar与text类型的区别和选用

    关于char,varchar与text平时没有太在意,一般来说,可能现在大家都是用varchar.但是当要存储的内容比较大时,究竟是选择varchar还是text呢?不知道...... 于是去查阅了一 ...

  9. mysql中char与varchar的区别分析(补充一句,int和integer没区别)

    转自:http://www.jb51.net/article/23575.htm 在mysql教程中char与varchar的区别呢,都是用来存储字符串的,只是他们的保存方式不一样罢了,char有固定 ...

随机推荐

  1. 如何安装 Microsoft Office 兼容包,以便您可以在早期版本的 Microsoft Office 中打开和保存 Office Open XML 格式

    https://support.microsoft.com/zh-cn/kb/923505 针对 Office 2003 的支持已终止 Microsoft 已于 2014 年 4 月 8 日终止了针对 ...

  2. Faster RCNN原理分析(二):Region Proposal Networks详解

    Faster RCNN原理分析(二):Region Proposal Networks详解 http://lib.csdn.net/article/deeplearning/61641 0814: A ...

  3. 关系型数据库和NoSQL数据库

    一.数据库排名和流行趋势 1.1 Complete ranking 链接: https://db-engines.com/en/ranking 在这个网站列出了所有数据库的排名,还可以看到所属数据库类 ...

  4. hello-R

    #print start { #: is array :) { print(:i) } } #print end #if start { x<- ) print(x) else print(&q ...

  5. 我练就数据分析技能从HR转型为产品经理

    本文转自知乎 作者:空白白白白 ----------------------------------------------------- 空白白白白写在前面:当我在奥兰多的时候,一位漂亮的女学员(看 ...

  6. 1.如何在Cloud Studio上执行Python代码?

    1.在python文件下新建python文件,输入文件名后按Enter键生成,比如: one.py . 2.简单输入python代码: print "haha" 3.打开左下角的终 ...

  7. Valgrind简单用法 (转)

    转自 http://www.cnblogs.com/sunyubo/archive/2010/05/05/2282170.html Valgrind的主要作者Julian Seward刚获得了今年的G ...

  8. Java相关文章

    servlet/filter/listener/interceptor区别与联系 web.xml配置详解 在Eclipse中使用JUnit4进行单元测试(初级篇) 单点登录原理与简单实现 spring ...

  9. LeetCode OJ 93. Restore IP Addresses

    题目 Given a string containing only digits, restore it by returning all possible valid IP address comb ...

  10. LeetCode OJ 19. Remove Nth Node From End of List

    Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...