For simple shredding cases, you can use the INSERT statement to shred the JSON data into a table. For example, consider the following JSON data:
{"pkey":123,"val":1234}
You can use the following INSERT statement to shred this data into the MyTable table:
INSERT INTO MyTable JSON '{"pkey":123,"val":1234}';
You can also use the JSON_TABLE table operator to shred this data, but the SQL is more complicated than using the INSERT statement.
INSERT INTO MyTable SELECT pkey, val FROM JSON_Table ( ON (SELECT 1, new JSON ('{"pkey":123,"val":1234}')) USING rowexpr('$') colexpr('[{"jsonpath" : "$.pkey", "type" : "INTEGER"}, {"jsonpath" : "$.val", "type" : "INTEGER"}]') ) AS JT(dummy, pkey, val);
Another advantage of using the INSERT statement is that this operation is a one-AMP operation when shredding JSON data that is a string literal. This can improve performance.
For parameterized SQL, INSERT JSON supports VARCHAR, CLOB, and external JSON data types. However, the operation is handled as a two-AMP process. For improved performance, directly specify a JSON literal.