zoukankan      html  css  js  c++  java
  • 创建数据表的时候 varchar可变类型的奇怪现象

    varchar的长度最大是65535字节
    创建的时候varchar(n) 这里面的n是字符长度
    所以编码格式不一样,n的最大值也不一样
    编码格式为Latin1时 n理论最大值为 65535
    编码格式为gbk时 n理论最大值为 65535/2 = 32767
    编码格式为utf8时 n理论最大值为 65535/3 = 21845
    当设置的n接近理论最大值的时候,会报错提示
    Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
    小于最大值一点儿(几或者几十),会创建成功varchar类型的
    接近最大值创建不成功
    但当超过理论最大值的时候,会创建成功为mediumtext类型的值
    神不神奇???
    例子
    CREATE TABLE test1 ( a varchar(65500) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE test2 ( a varchar(65535) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE test3 ( a varchar(65536) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
  • 相关阅读:
    jvm类加载机制
    线程误区-join,wait(里边还是调用的wait)
    线程间通信wait和notify【All】简介
    指令重排序
    window.opener
    scrollIntoView()
    保持饥饿,保持愚蠢
    执行sql语句,不依靠实体 获取string值
    join函数详解
    html常用代码大全
  • 原文地址:https://www.cnblogs.com/tobemaster/p/12494286.html
Copyright © 2011-2022 走看看