zoukankan      html  css  js  c++  java
  • The CHAR and VARCHAR Types

    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

  • 相关阅读:
    怎么使用git来管理项目版本?
    《我的四季》 张浩
    [代码片段]读取BMP文件(二)
    [代码片段]读取BMP文件
    《构建之法》阅读笔记02
    二维数组
    学习进度二
    《构建之法》阅读笔记01
    数组
    软件工程第一周开课博客
  • 原文地址:https://www.cnblogs.com/tekkaman/p/6358723.html
Copyright © 2011-2022 走看看