JSON - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

Specifies JSON format input. See Rules for Using the JSON Option.

For information about formatting JSON data, see Teradata Vantage™ JSON Data Type, B035-1150.

'JSON_string'
Specifies a literal string of data in JSON format.
?
Specifies parameterized SQL.
For parameterized SQL, INSERT...JSON supports VARCHAR, CLOB, and external JSON data types. However, the operation is a two-AMP process. For optimal performance, specify a JSON literal.

Examples: Inserting Data in JSON Format

Below is the table definition for the following example.

CREATE TABLE MyTable (
pkey INTEGER, 
val INTEGER, 
j JSON AUTO COLUMN);

This statement inserts the value 10 into the column pkey and the value 1234 into the column val. Because the table does not have a column named extra, the value 1234 is inserted into the auto column j.

INSERT INTO MyTable JSON '{"pkey":10,"val":1234,"extra":"1234"}';

This statement inserts parameterized SQL, represented by the question mark (?), into the table MyTable for a client that supports parameterized SQL.

INSERT INTO MyTable JSON ?;
Below is the table definition for the following example.
CREATE TABLE LDITable, WITH ISOLATED LOADING (
pkey INTEGER, 
val INTEGER, 
j JSON AUTO COLUMN);

This statement inserts into the load isolated table LDITable.

INSERT WITH ISOLATED LOADING INTO LDITable 
'{"pkey":10,"val":1234,"extra":"1234"}';

Below is the table definition for the example that follows. The table jsonTable includes the auto column j which must contain a value.

CREATE TABLE jsonTable (
a INTEGER, 
b INTEGER, 
j JSON AUTO COLUMN NOT NULL);

These statements insert three rows of data in the table JsonTable.

INSERT jsonTable JSON '{"a":1,"b":1,"extra":1}';
INSERT jsonTable JSON '{"a":2,"b":2,"extra1":2,"extra2":222}';
INSERT jsonTable JSON '{"a":3,"b":3};

Because the table does not have a column named extra, extra1, or extra 2, the values specified for extra, extra1, and extra2 are inserted into the auto column j. The third insert statement only specifies values for columns a and b. Because column j is defined as NOT NULL, an empty set of brackets ({}) is inserted in the third row for column j.

SELECT * FROM jsonTable ORDER BY 1;
          a           b j
----------- ----------- --------------------------------------
          1           1 {"extra":"1"}
          2           2 {"extra1":"2","extra2":"222"}
          3           3 {}