参考手册上不是说varchar(M),M的范围是0到65,535,而事实上我设个30000字段类型自动变成了 mediumtext类型,这是为什么?还有个问题就是我一个表里面有很多个varchar(1024)的字段,结果有次又往后面加个varchar(1024)发现插入数据就会失败,难道mysql对每条数据的总字节也有限制?限制是多少?

解决方案 »

  1.   

    varchar(M),M的范围是0到65,535
    ---------------
    这个是表示字节的长度,不是字符的长度,注意!!!
      

  2.   

    用命令
    show charset
    看看你系统选择的字符集的每个字符的长度是多少吧
      

  3.   

    utf8  3字节 第一个问题理解了 
    谢谢 那后面那个问题呢?
      

  4.   

    There is a hard limit of 4096 columns per table, but the effective maximum may be less for a given table. The exact limit depends on several interacting factors, listed in the following discussion. Every table has a maximum row size of 65,535 bytes. This maximum applies to all storage engines, but a given engine might have additional constraints that result in a lower effective maximum row size. 
      

  5.   

    总列数是限制,<4096 
    一条记录的大小也有限制  <65,535 bytes