CREATE TABLE jsonTable2 ( a INTEGER, b INTEGER, c INTEGER NOT NULL DEFAULT 5, j JSON CHARACTER SET LATIN );
In the following INSERT statement, the input JSON data does not include a value for column c. However, because the input JSON data is a string literal, the DEFAULT value defined for column c is inserted.
INSERT INTO jsonTable2 JSON '{"a":1234,"b":2}';
*** Insert completed. One row added. ***
CREATE TABLE jsonTable5 ( a INTEGER, b INTEGER, j JSON AUTO COLUMN NOT NULL );
In this example, the input JSON data includes extra data that does not match any columns in jsonTable5. The extra data is inserted into the j AUTO COLUMN. The third INSERT statement does not include any extra data and the AUTO COLUMN is defined as NOT NULL; therefore, '{}' is inserted.
INS jsonTable5 JSON '{"a":1,"b":1,"extra":1}'; INS jsonTable5 JSON '{"a":2,"b":2,"extra1":2,"extra2":222}'; INS jsonTable5 JSON '{"a":3,"b":3};
SELECT * FROM jsonTable5 ORDER BY 1;
a b j ----------- ----------- --------------------------------------------------- 1 1 {"extra":"1"} 2 2 {"extra1":"2","extra2":"222"} 3 3 {}