MySQL error: key specification without a key length

前端 未结 16 1107
别跟我提以往
别跟我提以往 2020-11-22 08:41

I have a table with a primary key that is a varchar(255). Some cases have arisen where 255 characters isn\'t enough. I tried changing the field to a text, but I get the foll

16条回答
  •  礼貌的吻别
    2020-11-22 09:04

    Don't have long values as primary key. That will destroy your performance. See the mysql manual, section 13.6.13 'InnoDB Performance Tuning and Troubleshooting'.

    Instead, have a surrogate int key as primary (with auto_increment), and your loong key as a secondary UNIQUE.

提交回复
热议问题