一、JSON类型
答案是不可以
为Json类型建索引会报错
mysql> CREATE INDEX idx1 ON user (card_pay_data(10)); ERROR 3152 (42000): JSON column 'card_pay_data' cannot be used in key specification.
二、text类型
答案是可以的,但是需要指定长度
mysql> CREATE INDEX idx2 ON user (tests); ERROR 1170 (42000): BLOB/TEXT column 'tests' used in key specification without a key length mysql> CREATE INDEX idx2 ON user (tests(10)); Query OK, 0 rows affected (0.03 sec) Records: 0 Duplicates: 0 Warnings: 0