一.JSON类型 答案是不可以 为Json类型建索引会报错 mysql)); ERROR (): JSON column 'card_pay_data' cannot be used in key specification. 二.text类型 答案是可以的,但是需要指定长度 mysql> CREATE INDEX idx2 ON user (tests); ERROR (): BLOB/TEXT column 'tests' used in key specification without
SELECT name, profile->"$.twitter" AS `twitter` FROM `user` WHERE profile->"$.twitter" IS NOT NULL; https://dev.mysql.com/doc/refman/5.7/en/json-search-functions.html https://www.sitepoint.com/use-json-data-fields-mysql-databases/
MySQL 5.7.8开始支持 json类型. create table t(id int,js json,PRIMARY KEY (`id`)) 插入数据insert into t values(1,'{"a":1,"s":"abc"}')insert into t values(2,'[1,2,{"a":123}]')insert into t values(3,'"str"')insert into