Teradata Compression and Decompression Functions | Teradata Vantage - Teradata Compression and Decompression Functions - Teradata Vantage - Analytics Database

SQL Data Types and Literals

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
uds1628112204571.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
exs1472253032394
lifecycle
latest
Product Category
Teradata Vantage™

Teradata provides the following functions for compressing and uncompressing data. These functions are stored in the TD_SYSFNLIB system database.

Function Type UDF Name Description
Compress TransUnicodeToUTF8 Takes UNICODE character input and stores it in UTF-8 format.

This is useful when the characters are in the ASCII script (U+0000 to U+007F) because UTF-8 uses one byte to represent these characters and UNICODE (UTF-16) uses two bytes.

Decompress TransUTF8ToUnicode Takes the data previously compressed using the TransUnicodeToUTF8 function and converts it back to UNICODE.
Compress LZCOMP Compresses UNICODE character data using the Lempel-Ziv algorithm.
Decompress LZDECOMP Uncompresses UNICODE data that was compressed using LZCOMP.
Compress LZCOMP_L Compresses LATIN character data using the Lempel-Ziv algorithm.
Decompress LZDECOMP_L Uncompresses LATIN data that was compressed using LZCOMP_L.
Compress CAMSET Compresses UNICODE character data into partial byte (for example, 4-bit digits or 5-bit alphabetic letters), one byte, or two byte values using a proprietary Teradata algorithm.
Decompress DECAMSET Uncompresses the UNICODE character data that was compressed using CAMSET.
Compress CAMSET_L Compresses LATIN character data into partial byte (for example, 4-bit digits or 5-bit alphabetic letters), or one byte values using a proprietary Teradata algorithm.
Decompress DECAMSET_L Uncompresses the LATIN character data that was compressed using CAMSET_L.
Compress TD_LZ_COMPRESS Compresses any supported ALC data type or predefined type data using Lempel-Ziv coding.
Decompress TD_LZ_DECOMPRESS Uncompresses any supported ALC data type or predefined type data that was compressed using TZ_LZ_COMPRESS.
Compress TS_COMPRESS Compresses TIME and TIMESTAMP data.
Decompress TS_DECOMPRESS Uncompresses TIME and TIMESTAMP data that was compressed using TS_COMPRESS.
Compress JSON_COMPRESS Compresses JSON data.
Decompress JSON_DECOMPRESS Uncompresses the JSON data that was compressed using JSON_COMPRESS.

For more information about these functions, see Teradata Vantage™ - SQL Operators and User-Defined Functions, B035-1210.

If these functions do not provide optimal compression for your data, you may implement your own UDFs for use in compressing and uncompressing table columns. For more information, see Teradata Vantage™ - SQL External Routine Programming, B035-1147.

If you create custom ALC UDFs, make sure to test them thoroughly. If the compression or decompression algorithm fails, compressed data may not be recoverable, or may be corrupted.