Examples: Get the Storage Size Required for a Storage Format - 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: StorageSize with No Storage Format Specified

This example calls StorageSize with no storage format specified. The method defaults to using the storage format of the input data, which is LATIN text in this case.

SELECT NEW JSON('{"hello":"world"}').StorageSize() 
FROM jsonTable;

Result:

NEW JSON('{"hello":"world"}').StorageSize()
-------------------------------------------
                                         17 

Example: StorageSize with UNICODE Text Storage Format Specified

This example gets the number of bytes needed to store the LATIN text JSON input in UNICODE text format.

SELECT NEW JSON('{"hello":"world"}').StorageSize('UNICODE_TEXT') 
FROM jsonTable;

Result:

NEW JSON('{"hello":"world"}').StorageSize('UNICODE_TEXT')
---------------------------------------------------------
                                                       34 

Example: StorageSize with BSON Storage Format Specified

This example gets the number of bytes needed to store the LATIN text JSON input in BSON format.

SELECT NEW JSON('{"hello":"world"}').StorageSize('BSON') 
FROM jsonTable;

Result:

NEW JSON('{"hello":"world"}').StorageSize('BSON')
-------------------------------------------------
                                               22 

Example: StorageSize with UBJSON Storage Format Specified

This example gets the number of bytes needed to store the LATIN text JSON input in UBJSON format.

SELECT NEW JSON('{"hello":"world"}').StorageSize('UBJSON') 
FROM jsonTable;

Result:

NEW JSON('{"hello":"world"}').StorageSize('UBJSON')
---------------------------------------------------
                                                 23