https://cloud.tencent.com/developer/section/1419793
SQLite version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>
sqlite>
sqlite> create table a(sentenc JSON);
sqlite>
sqlite> insert into facts values(json_object("mascot", "Our mascot is a dolphin name sakila"));
Error: no such table: facts
sqlite> insert into a values(json_object("mascot", "Our mascot is a dolphin name sakila"));
sqlite>
sqlite> select * from a;
{"mascot":"Our mascot is a dolphin name sakila"}
sqlite>
sqlite>
sqlite>
sqlite> select json_object('ex',json_array(52,3.14159)) ;
{"ex":[52,3.14159]}
sqlite> select json_extract('{"a":2,"c":[3,2]}','$.c[1]','$.a');
[2,2]
sqlite>
sqlite> SELECT sentenc"$.a" FROM a;
{"mascot":"Our mascot is a dolphin name sakila"}
sqlite>
sqlite>
sqlite> SELECT sentenc"$.a" FROM a;
{"mascot":"Our mascot is a dolphin name sakila"}
sqlite>
sqlite>
sqlite>
sqlite>
sqlite>
sqlite>
sqlite> create table userj(userInfo JSON);
sqlite> insert into userj values('{"id":"19", "name":"Lida"}');
sqlite>
sqlite> insert into userj values('{"id":"20", "name":"james"}');
sqlite>
sqlite> select * from userj;
{"id":"19", "name":"Lida"}
{"id":"20", "name":"james"}
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj;
Lida
james
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where id = 19;
Error: no such column: id
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where "$.id" = 19;
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where "$.id" = "19";
sqlite> select json_type('["a", "b", 1]');
array
sqlite>
sqlite>
sqlite>
sqlite>
sqlite>
sqlite> select json_type('["a", "b", 1]');
array
sqlite>
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where keywords->"$.id" = "19";
Error: near ">": syntax error
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where keywords -> "$.id" = "19";
Error: near ">": syntax error
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where keywords -> '$.id' = "19";
Error: near ">": syntax error
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where keywords -> '$.id' = "19";
Error: near ">": syntax error
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where JSON_VALUE(jsonCol, '$.id') = "19";
Error: no such column: jsonCol
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where JSON_VALUE(userInfo, '$.id') = "19";
Error: no such function: JSON_VALUE
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where json_value(userInfo, '$.id') = "19";
Error: no such function: json_value
sqlite>
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where value(userInfo, '$.id') = "19";
Error: no such function: value
sqlite>
sqlite> SELECT json_extract(userInfo,"$.name") FROM userj where json_extract(userInfo, '$.id') = "19";
Lida
sqlite>
sqlite> SELECT json_set(userInfo,"$.name","aaaaa") FROM userj where json_extract(userInfo, '$.id') = "19";
{"id":"19","name":"aaaaa"}
sqlite>
sqlite> select json('{}');
{}
sqlite>
sqlite> select json('{"a":2}');
{"a":2}
sqlite>
sqlite> select json_extract('{"a":2}','$.a');
2
sqlite>
sqlite>
sqlite> select json_extract('{"a":2},[1,2]','$.a');
Error: malformed JSON
sqlite>
sqlite> select json_extract('{"a":2},["1","2"]','$.a');
Error: malformed JSON
sqlite>
sqlite> select json_extract('{"a":2,["1","2"]}','$.a');
Error: malformed JSON
sqlite>
sqlite> select json_extract('{"a":2}','$.a');
2
sqlite>
sqlite>
sqlite> select json_extract('{"a":2,"c":3}','$.a');
2
sqlite>
sqlite>
sqlite> select json_extract('{"a":2,"c":3}','$.a,$.c');
sqlite> select json_extract('{"a":2,"c":3}','$.a');
2
sqlite>
sqlite> select json_extract('{"a":2,"c":3,2}','$.a');
Error: malformed JSON
sqlite> select json_extract('{"a":2,"c":[3,2]}','$.a');
2
sqlite>
sqlite> select json_extract('{"a":2,"c":[3,2]}','$.c');
[3,2]
sqlite>
sqlite>
sqlite> select json_extract('{"a":2,"c":[3,2]}','$.c[0]');
3
sqlite>
sqlite>
sqlite> select json_extract('{"a":2,"c":[3,2]}','$.c[1]');
2
sqlite>
sqlite> select json_object('ex',json_array(52,3.14159)) ;
{"ex":[52,3.14159]}
sqlite> select json_extract('{"a":2,"c":[3,2]}','$.c[1]','$.a');
[2,2]
sqlite>
sqlite>
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE a(sentenc JSON);
INSERT INTO a VALUES('{"mascot":"Our mascot is a dolphin name sakila"}');
CREATE TABLE userj(userInfo JSON);
INSERT INTO userj VALUES('{"id":"19", "name":"Lida"}');
INSERT INTO userj VALUES('{"id":"20", "name":"james"}');
CREATE TABLE tj10 (a JSON, b INT);
INSERT INTO tj10 VALUES('[3,10,5,17,44]',33);
INSERT INTO tj10 VALUES('[3,10,5,17,[22,44,66]]',0);
COMMIT;
sqlite>