数据库报错 Specified key was too long; max key length is 3072 bytes
时间: 2023-10-13 19:04:10 浏览: 176
数据库报错 "Specified key was too long; max key length is 3072 bytes" 是由于创建联合索引时指定的索引键的长度超过了数据库的最大限制。根据引用,MySQL的varchar主键只支持不超过768个字节的长度。而根据引用,在UTF-8字符集下,一个字符占用3个bytes,因此对于UTF-8字符集,单列长度不能超过333个字符。如果使用UTF-8MB4字符集,一个字符将占用4个bytes,因此单列长度不能超过255个字符。解决这个问题的方法是缩短索引键的长度,确保不超过数据库的限制。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Specified key was too long; max key length is 3072 bytes](https://blog.csdn.net/qq_39156616/article/details/125395815)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Spark SQL 与 Hive 交互报错:Specified key was too long; max key length is 3072 bytes](https://blog.csdn.net/weixin_37417954/article/details/93894227)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文