美文网首页
MySQL[Specified key was too long

MySQL[Specified key was too long

作者: BETWEENAND | 来源:发表于2019-07-07 20:17 被阅读0次

    MySQL Version: 5.5.27

    // Specified key was too long; max key length is 767 bytes
    
    CREATE TABLE QRTZ_JOB_DETAILS
      (
        SCHED_NAME VARCHAR(120) NOT NULL,
        JOB_NAME  VARCHAR(200) NOT NULL,
        JOB_GROUP VARCHAR(200) NOT NULL,
        DESCRIPTION VARCHAR(250) NULL,
        JOB_CLASS_NAME   VARCHAR(250) NOT NULL,
        IS_DURABLE VARCHAR(1) NOT NULL,
        IS_NONCONCURRENT VARCHAR(1) NOT NULL,
        IS_UPDATE_DATA VARCHAR(1) NOT NULL,
        REQUESTS_RECOVERY VARCHAR(1) NOT NULL,
        JOB_DATA BLOB NULL,
        PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
    )
    # 错误是因为utf8字节的计算方式,每个字符占3字节。 120 * 200 * 200 * 3。所以报错
    
    # 解决方式
    # 首先要保证数据库引擎是使用 innodb. 
    show global variables like "innodb_large_prefix";
    show global variables like "innodb_file_per_table";
    show variables like 'innodb_file_format';
    
    SET GLOBAL innodb_large_prefix = on;
    SET GLOBAL innodb_file_per_table = on;
    SET GLOBAL innodb_file_format = BARRACUDA;
    
    # 在创建语句后加 row_format = dynamic
    

    相关文章

      网友评论

          本文标题:MySQL[Specified key was too long

          本文链接:https://www.haomeiwen.com/subject/fpuihctx.html