四、mysql操作
阿新 • • 發佈:2018-08-31
lte alt json數據 trac mysql true xtra var dex
JSON數據的操作
CREATE TABLE IF NOT EXISTS table_json (id BIGINT auto_increment,json JSON,PRIMARY KEY(id)); ALTER TABLE table_json add COLUMN name VARCHAR(128) GENERATED ALWAYS AS (JSON_EXTRACT(json, "$.name")) virtual; ALTER TABLE table_json add COLUMN name VARCHAR(128) GENERATED ALWAYS AS (JSON_EXTRACT(json, "$.name")) stored; ALTER TABLE table_json ADD FULLTEXT INDEX idx_fulltext_name(name_store) ALTER TABLE table_json ADD INDEX name(name); ALTER TABLE table_json DROP INDEX name; CREATE TABLE IF NOT EXISTS table_json (id BIGINT auto_increment,json JSON,name VARCHAR(128) GENERATED ALWAYS AS (json->"$.name") virtual,PRIMARY KEY(id),INDEX name_index(name)); SELECT JSON_EXTRACT(json, "$.name") from table_json; SELECT name FROM table_json;
四、mysql操作