首页 > 其他 > 详细

The CHAR and VARCHAR Types

时间:2017-01-31 12:57:22      阅读:243      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/tekkaman/p/6358723.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!