1、建表
CREATE TABLE `test` (
`id` bigint NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`msg` json NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
2、插入语句
INSERT INTO `test`
VALUES
( 3, 'feng', '{"email": "[email protected]", "phone": "+11800000000", "address": {"pin": "560103", "city": "Bangalore", "line1": "abc", "line2": "xyz street"}, "location": "IN"}' );
3、查询
select id,name, msg -> '$.phone' ph, msg -> '$.address.city' city from test;
标签:city,utf8mb4,mysql8,json,msg,NULL,存取,id From: https://www.cnblogs.com/innocenter/p/17349336.html