INSERT INTO t1 VALUES ROW(’{"id": "123", "name": "shoes", "price": "49.95"}’); 

A query using this expression, such as that shown here, can make use of the index: 

SELECT name, price FROM t1 WHERE JSON_VALUE(j, ’$.id’ RETURNING UNSIGNED) = 123; 

In many cases, this is simpler than creating a generated column from the JSON  column and then creating an index on the generated column. 

For more information and examples, see the description of JSON_VALUE() . 

• User comments and user attributes.  MySQL 8.0.21 introduces the ability to set user comments and user attributes when creating or updating user accounts. A user comment consists of arbitrary text passed as the argument to a COMMENT  clause used with a CREATE USER  or ALTER USER  statement. A user attribute consists of data in the form of a JSON object passed as the argument to an ATTRIBUTE clause used with either of these two statements. The attribute can contain any valid key-value pairs in JSON object notation. Only one of COMMENT  or ATTRIBUTE  can be used in a single CREATE USER  or ALTER USER  statement. 

User comments and user attributes are stored together internally as a JSON object, the comment text as the value of an element having comment  as its key. This information can be retrieved from the ATTRIBUTE  column of the INFORMATION_SCHEMA.USER_ATTRIBUTES  table; since it is in JSON format, you can use MySQL’s JSON function and operators to parse its contents (see Section 12.18, “JSON Functions” ). Successive changes to the user attribute are merged with its current value as when using the JSON_MERGE_PATCH()  function. 

Example: 

mysql> CREATE USER ’mary’@’localhost’ COMMENT ’This is Mary Smith\’s account’; Query OK, 0 rows affected (0.33 sec) mysql> ALTER USER ’mary’@’localhost’ - ≫ ATTRIBUTE ’{"fname":"Mary", "lname":"Smith"}’; Query OK, 0 rows affected (0.14 sec) mysql> ALTER USER ’mary’@’localhost’ - ≫ ATTRIBUTE ’{"email":"mary.smith@example.com"}’; Query OK, 0 rows affected (0.12 sec) mysql> SELECT -> USER, -> HOST, -> ATTRIBUTE->>"$.fname" AS ’First Name’, -> ATTRIBUTE->>"$.lname" AS ’Last Name’, -> ATTRIBUTE->>"$.email" AS ’Email’, -> ATTRIBUTE->>"$.comment" AS ’Comment’ -> FROM INFORMATION_SCHEMA.USER_ATTRIBUTES -> WHERE USER=’mary’ AND HOST=’localhost’\G *************************** 1. row *************************** USER: mary HOST: localhost First Name: Mary  Last Name: Smith Email: mary.smith@example.com Comment: This is Mary Smith’s account 1 row in set (0.00 sec) 

For more information and examples, see Section 13.7.1.3, “CREATE USER Statement” , Section 13.7.1.1, “ALTER USER Statement” , and Section 26.3.46, “The INFORMATION_SCHEMA USER_ATTRIBUTES Table” . 

