Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A brief Analysis of MySQL 5.7Json Operation

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following content mainly brings you a brief analysis of the operation of MySQL 5.7Json. The knowledge mentioned here, which is slightly different from books, is summed up by professional and technical personnel in the process of contact with users, and has a certain value of experience sharing, hoping to bring help to the majority of readers.

Create a tabl

CREATE TABLE t_json (id INT PRIMARY KEY, NAME VARCHAR (20), info JSON)

Insert record

INSERT INTO t_json (id,sname,info) VALUES (1, 'test',' {"time": "2017-01-01 13:00:00", "ip": "192.168.1.1", "result": "fail"}'); INSERT INTO t_json (id,sname,info) VALUES (2, 'my',JSON_OBJECT ("time", NOW (),' ip','192.168.1.1','result','fail'))

Query IP key

SELECT sname,JSON_EXTRACT (info,'$.ip') FROM t_json

Query how many keys there are

SELECT id,json_keys (info) AS "keys" FROM t_json

Delete key

UPDATE t_json SET info = json_remove (info,'$.ip')

Add key

UPDATE t_json SET info = json_set (info,'$.ip','192.168.1.1')

Change value

UPDATE t_json SET info = json_set (info,'$.ip','192.168.1.2')

For the above brief analysis of MySQL 5.7Json operation, if you need to know more, you can continue to pay attention to the innovation of our industry, if you need to get professional answers, you can contact the pre-sale and after-sale on the official website. I hope this article can bring you some knowledge updates.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report