In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to insert json into MySQL. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
After MySQL5.7.8, a native JSON type that efficiently fetches data in JSON text is supported, which has the following advantages:
Automatic verification when storage, verification does not pass the error report
Better storage structure. Uses an internal structure for telling JSON text elements to be read. The new server reads an JSON text in binary format rather than string format and then converts it. This binary format allows the server to get its child objects (nested arrays) through keys or array indexes in text without having to read all values.
In addition, the system places some restrictions on the JSON format:
The maximum length of JSON text depends on the system constant: max_allowed_packet. This value is limited only when the server is storing, and it is allowed to be exceeded when calculating in memory.
JSON column cannot have default values
JSON columns, like other binary type columns, cannot be indexed. However, indexes can be created from some table values in the text stored in the JSON column. The MySQL optimal controller is also queried in indexes created by JSON expressions.
Problems encountered when inserting json data
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near'{
Insert code
Insert into `players` (`id`, `player_and_ games`) values (1, {"id": 1, "name": "aaa", "games_played": {"Battlefiedld": {"weapon": "adsf", "level": 20}, "Crazy": {"weapon": "adsf", "level": 20})
There is a problem. Json does not use quotation marks. The correct way is as follows
Insert into `players` (`id`, `player_and_ games`) values (1)'{"id": 1, "name": "aaa", "games_played": {"Battlefiedld": {"weapon": "adsf", "level": 20}, "Crazy": {"weapon": "adsf", "level": 20}}') this is how to insert json into MySQL. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.