JSON_COMPRESS
Purpose
Compresses JSON data type values.
Syntax
where:
Syntax element… |
Specifies… |
TD_SYSFNLIB |
the name of the database where the function is located. |
JSON_expr |
an expression that evaluates to a JSON data type. |
Note: This function takes no arguments when used as part of the COMPRESS USING or DECOMPRESS USING phrases. For more information about the COMPRESS/DECOMPRESS phrase, see SQL Data Types and Literals.
ANSI Compliance
This is a Teradata extension to the ANSI SQL:2011 standard.
Argument Type and Rules
This function only compresses JSON data types. It cannot be used to compress any other data type. Users cannot create their own UDFs for compressing JSON data.
Result Type
The function accepts TD_ANYTYPE as input and returns TD_ANYTYPE so it can be used on any form of the JSON data type.
Usage Notes
You can use the TD_LZ_COMPRESS function to compress JSON data; however, Teradata recommends that you use JSON_COMPRESS instead because the JSON_COMPRESS function is optimized for compressing JSON data.
Example
Although you can call the function directly, JSON_COMPRESS is often used with the COMPRESS USING phrase to compress table columns. In the following table, the JSON data in the json_col column is compressed using the JSON_COMPRESS function.
CREATE TABLE temp (
id INTEGER,
json_col JSON(1000)
CHARACTER SET LATIN
COMPRESS USING JSON_COMPRESS
DECOMPRESS USING JSON_DECOMPRESS);
For more information about the COMPRESS USING phrase, see SQL Data Types and Literals.