测试如下:
mysql:
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 8.0.35 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(root@10.110.66.172) [(none)]>use test
(root@10.110.66.172) [(none)]>use test;
Database changed
(root@10.110.66.172) [test]>CREATE TABLE a (
-> id INT AUTO_INCREMENT PRIMARY KEY,
-> data JSON
-> );
Query OK, 0 rows affected (0.05 sec)
(root@10.110.66.172) [test]>INSERT INTO a (data)
-> VALUES ('{"name": "小明", "age": 30, "city": "北京"}');
Query OK, 1 row affected (0.01 sec)
(root@10.110.66.172) [test]>select * from a;
+----+-------------------------------------------------+
| id | data |
+----+-------------------------------------------------+
| 1 | {"age": 30, "city": "北京", "name": "小明"} |
+----+-------------------------------------------------+
1 row in set (0.00 sec)
tidb:
(root@10.102.58.180) [(none)]>use test;
Database changed
(root@10.102.58.180) [test]>CREATE TABLE a (
-> id INT AUTO_INCREMENT PRIMARY KEY,
-> data JSON
-> );
Query OK, 0 rows affected (0.14 sec)
(root@10.102.58.180) [test]>INSERT INTO a (data)
-> VALUES ('{"name": "小明", "age": 30, "city": "北京"}');
Query OK, 1 row affected (0.01 sec)
(root@10.102.58.180) [test]>select * form a;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 13 near "form a"
(root@10.102.58.180) [test]>select * from a;
+----+-------------------------------------------------+
| id | data |
+----+-------------------------------------------------+
| 1 | {"age": 30, "city": "北京", "name": "小明"} |
+----+-------------------------------------------------+
1 row in set (0.00 sec)
所以行为是一致的。而且对于 json 格式来说,展示上的顺序我理解没啥关系,内容一样的 ![]()