Example: Get an Ordered List of Unique Keys From Documents - 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ā„¢

The example uses JSON_KEYS to get an ordered list of all unique keys from all documents of all rows of a table.

SELECT distinct(JSONKeys) from JSON_KEYS
(
ON (SELECT json_data FROM json_table))
AS json_data
ORDER BY 1;
Result:
JSONKeys
--------
"base"
"clouds"
"clouds"."all"
"cod"
"coord"
"coord"."lat"
"coord"."lon"
"dt"
"id"
"main"
"main"."humidity"
"main"."pressure"
"main"."temp"
"main"."temp_max"
"main"."temp_min"
"main"."temp_scale"
"name"
"sys"
"sys"."country"
"sys"."sunrise"
"sys"."sunset"
"weather"
"weather"[0]
"weather"[0]."description"
"weather"[0]."icon"
"weather"[0]."id"
"weather"[0]."main"
"wind"
"wind"."deg"
"wind"."speed"