这是因为在设置联合主键时,如果采用UTF-8编码,那么只能存储1024/3=300多个单位长度。
所以长度不能超过300.
比如:
CREATE TABLE TIMMS10 ( CLUSTER_ID VARCHAR(32) DEFAULT ' ' NOT NULL, APP_ID VARCHAR(32) DEFAULT ' ' NOT NULL, IP_ADDRESS VARCHAR(30) DEFAULT ' ' NOT NULL, USER_NAME VARCHAR(10) DEFAULT ' ' NOT NULL, LOCALE VARCHAR(10) DEFAULT ' ' NOT NULL, MONITOR_SEQ DECIMAL(8,0) DEFAULT 0 NOT NULL, DIAGNOSE_ID DECIMAL(20,0) DEFAULT 0 NOT NULL, SESSION_ID VARCHAR(100) DEFAULT ' ' NOT NULL, THREAD_ID VARCHAR(100) DEFAULT ' ' NOT NULL, JOB_ID DECIMAL(5,0) DEFAULT 0 NOT NULL, JOB_PARENT_ID DECIMAL(5,0) DEFAULT 0 NOT NULL, JOB_CONTEXT VARCHAR(500) DEFAULT ' ' NOT NULL, JOB_TYPE VARCHAR(20) DEFAULT ' ' NOT NULL, JOB_START_TIME VARCHAR(18) DEFAULT ' ' NOT NULL, JOB_END_TIME VARCHAR(18) DEFAULT ' ' NOT NULL, JOB_COST DECIMAL(20,0) DEFAULT 0 NOT NULL, JOB_START_CLASS VARCHAR(100) DEFAULT ' ' NOT NULL, JOB_START_METHOD VARCHAR(50) DEFAULT ' ' NOT NULL, JOB_START_FILE VARCHAR(50) DEFAULT ' ' NOT NULL, JOB_START_LINE VARCHAR(5) DEFAULT ' ' NOT NULL, JOB_END_CLASS VARCHAR(100) DEFAULT ' ' NOT NULL, JOB_END_METHOD VARCHAR(50) DEFAULT ' ' NOT NULL, JOB_END_FILE VARCHAR(50) DEFAULT ' ' NOT NULL, JOB_END_LINE VARCHAR(5) DEFAULT ' ' NOT NULL, JOB_INFO VARCHAR(2000) DEFAULT ' ' NOT NULL, JOB_LEAF VARCHAR(1) DEFAULT ' ' NOT NULL, JOB_OK VARCHAR(1) DEFAULT ' ' NOT NULL, JOB_ERROR VARCHAR(500) DEFAULT ' ' NOT NULL, CONSTRAINT TIMMS10_PK PRIMARY KEY (CLUSTER_ID, APP_ID, MONITOR_SEQ, DIAGNOSE_ID, JOB_ID) );
注意观察最后的主键,是5个字段组合起来的联合主键,它们加起来的长度不能超过300,否则报错。
相关推荐
今天在为数据库中的某两个字段设置unique索引的时候,出现了Specified key was too long; max key length is 1000 bytes错误
本文将详细提供mysql建库时提示Specified key was too long max key length is 1000 bytes的问题的解决方法,有需求的朋友可以参考
nacos-server-1.1.4 windows下的运行程序 springcloud alibaba
ALTER TABLE table1 ALTER COLUMN ... 您可能感兴趣的文章:sql server建库、建表、建约束技巧mysql建库时提示Specified key was too long max key length is 1000 bytes的问题的解决方法Mysql 建库建表技巧分享SQL S
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_...
导致报 Specified key was too long; max key length is 767 bytes 解决方案1: 直接缩短到255长度 解决方案2: 修改数据库配置, set innodb_large_prefix=on 吐槽一下, 1.2.0版本比1.1.4版本多创建一...
String Keys are UTF8 encoded and limited to 60 bytes if not specified otherwise (maximum is 255 chars). Support for long string Keys with the RaptorDBString class. Duplicate keys are stored as a WAH ...
On production servers, 4096 bytes is a good setting for performance ; reasons. ; Note: Output buffering can also be controlled via Output Buffering Control ; functions. ; Possible Values: ; On = ...
- When x86-64 support is compiled in, you could enable/disable long mode 1G pages support without recompile using new CPUID option in .bochsrc. Configure options: --enable-mmx, --enable-sse, --...