Example: Create Tables with JSON Data Type Columns - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

This example creates a table with a JASON column that is non-LOB.

CREATE TABLE jsonTable1(id INTEGER,
                       jsn1 JSON(64000) CHARACTER SET LATIN);

This example creates a table with non-LOB and LOB JASON columns.

CREATE TABLE jsonTable2(id INTEGER,
                jsn1 JSON(1000) CHARACTER SET LATIN,
                jsn2 JSON INLINE LENGTH 30000 CHARACTER SET LATIN);

This example uses a different syntax to create the same structure as jsonTable2, a table with non-LOB and LOB JASON columns.

CREATE TABLE jsonTable3(id INTEGER,
               jsn1 JSON(1000) INLINE LENGTH 1000 CHARACTER SET LATIN,
               jsn2 JSON INLINE LENGTH 30000 CHARACTER SET LATIN);

This example creates a table with the following types of JSON columns: non-LOB and LOB with specified inline lengths. When the specified maximum length is equal to the inline length, the CDT is a non-LOB type.

CREATE TABLE jsonTable4(id INTEGER,
               jsn1 JSON(30000) INLINE LENGTH 30000,
               jsn2 JSON INLINE LENGTH 100);

This example creates a table with an JSON column that is an LOB with a specified inline length.

CREATE TABLE jsonTable5(id INTEGER,
                 jsn1 JSON(64000) INLINE LENGTH 100);

This example creates a table with an JSON column that is non-LOB with a specified inline length and a Binary JSON storage format.

CREATE TABLE jsonTable6(id INTEGER,
               jsn1 JSON(64000) INLINE LENGTH 64000 STORAGE FORMAT BSON);

This example creates a table with an JSON column that is non-LOB with a specified inline length and a Universal Binary JSON storage format.

CREATE TABLE jsonTable7(id INTEGER,
               jsn1 JSON(64000) INLINE LENGTH 64000 STORAGE FORMAT UBJSON);