Examples: Using the USING QUOTES Clause - Advanced SQL Engine - Teradata Database

JSON Data Type

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

Example: USING QUOTES ('Y')

In this example, JSON_KEYS is invoked with the USING QUOTES ('Y') clause; therefore, the key names returned in the result are enclosed in double quotation marks.

SELECT * FROM JSON_KEYS 
(ON (SELECT NEW JSON('{ "x":{"a":{"b":3}}  , "y" : "b"}')) USING QUOTES('Y')) 
AS json_data;

Result:

KEYS
----
"x"
"x"."a"
"x"."a"."b"
"y"

Example: USING QUOTES ('N')

In this example, JSON_KEYS is invoked with the USING QUOTES ('N') clause; therefore, the key names returned in the result are not enclosed in double quotation marks.

SELECT * FROM JSON_KEYS 
(ON (SELECT NEW JSON('{ "x":{"a":{"b":3}}  , "y" : "b"}')) USING QUOTES('N')) 
AS json_data;

Result:

KEYS
----
x
x.a
x.a.b
y

Example: USING QUOTES Is Not Specified

In this example, JSON_KEYS is invoked without specifying the USING QUOTES clause. The default behavior is to return the key names enclosed in double quotation marks.

SELECT * FROM JSON_KEYS 
(ON (SELECT NEW JSON('{ "x":{"a":{"b":3}}  , "y" : "b"}'))) 
AS json_data;

Result:

KEYS
----
"x"
"x"."a"
"x"."a"."b"
"y"