Get the App
SLTechnology News&Howtos  ›  Database  › 

Introduction and usage of MySQL 5.7.7 JSON types

Shulou Source: shulou.com Published: 2022-06-01 19:47:45 10月14日 Update

The following mainly brings you the introduction and usage of MySQL 5.7.7 JSON type. I hope that the introduction and usage of MySQL 5.7.7 JSON type can bring you practical use, which is also the main purpose of my editing this article. All right, don't talk too much nonsense, let's just read the following.

Starting with MySQL 5.7.7, the JSON type is supported.

CREATE TABLE IF NOT EXISTS `spss`.`variable` (`name`VARCHAR) NOT NULL, `type` JSON NOT NULL, `width` INT NOT NULL, `decimals` INT NOT NULL, `label`NOT NULL, `values`JSON NOT NULL, `missing`JSON NOT NULL, `columns`INT NOT NULL, `align`ENUM ('Left',' Right', 'Center') NOT NULL, `feature` ENUM (' Scale', 'Ordinal',' Norminal') NOT NULL, `role`ENUM ('Input',' Target', 'Both',' None') 'Partation',' Split') NOT NULL, PRIMARY KEY (`name`) ENGINE = InnoDB Insert into variable values ('S1th,' {"Numeric": "8:0"}', 8, 0, 'your gender?','{"1": "male", "2": "female"}','{"Missing": "None"}', 8 Input') Insert into variable values ('S2values`,' {"Numeric": "8:0"}', 8,0, 'your actual age?','{}','{}', 'Input''); select * from variable where JSON_Extract (`values`,'$. "1") = 'male'; select * from variable where `values`->'$. "1'= 'male'; select * from variable where measure = 'male'

A few points to note:

The use of the ENUM type.

The use of the JSON type.

In the JSON type, if the keyword is a number:'{"1": "male", "2": "female"}', enclose the number in double quotes when querying: `values`->'$. "1"'

When the column name is the SQL keyword, wrap the column name with the character "`", such as `values` in the example above.

For the above introduction and usage of MySQL 5.7.7 JSON type, do you find it very helpful? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Tags: Type following key content actual number example keyword package such as above character age nonsense quotation marks gender more usefulness purpose article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft Redmi Huawei NVidia