Home  >  Article  >  Database  >  MySql修改或者创建索引是的错误提示:ERROR 1170 (42000): BLOB/T_MySQL

MySql修改或者创建索引是的错误提示:ERROR 1170 (42000): BLOB/T_MySQL

WBOY
WBOYOriginal
2016-06-01 13:30:352129browse

bitsCN.com


MySql修改或者创建索引是的错误提示:ERROR 1170 (42000): BLOB/T...解决

 

在创建或修改mysql索引时出现了这样的错误:

 

ERROR 1170 (42000): BLOB/TEXT column 'col2' used in key specification without a key length

 

看了下该表的数据结构发现col2字段类型是text ,查询了下发现是:

 

MySQL只能将BLOB/TEXT类型字段设置索引为BLOB/TEXT数据的钱N个字符.

索引指定下col2的长度就可以了 :

 

alter table foo add index col_2 (col2(10))

 

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn