15.00 - TD_LZ_COMPRESS - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

TD_LZ_COMPRESS

Purpose  

Compresses any supported ALC data type or predefined type data using the Lempel‑Ziv algorithm.

Syntax  

where:

 

Syntax element…

Specifies…

TD_SYSFNLIB

the name of the database where the function is located.

expression

  • any supported ALC data type when using the function as the compression routine for ALC on a column.
  • any supported ALC data types and all predefined data types and Distinct UDTs when calling the function.
  • 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

    Expressions passed to this function must have one of the following data types:

  • BYTE
  • VARBYTE
  • CHARACTER
  • VARCHAR
  • JSON
  • TIME
  • TIMESTAMP
  • System-defined UDTs, such as ST_Geometry and XML.
  • Distinct UDTs, including LOB UDTs, ARRAY or Period data types.
  • Data types must match the result data type of the corresponding decompression function, TD_LZ_DECOMPRESS.

    Result Type

    The result data types are VARBYTE or BLOB.

    Usage Notes

    Numeric data types are valid when calling the function in an SQL statement, but not when using the function for ALC on a column.

    If TD_LZ_COMPRESS is used with ALC, nulls are also compressed if those columns are nullable.

    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.

    Uncompressing Data Compressed with TD_LZ_COMPRESS

    To uncompress data that was compressed using TD_LZ_COMPRESS, use “TD_LZ_DECOMPRESS” on page 546.

    Related Topics

     

    For information on …

    See …

    ALC

    “COMPRESS and DECOMPRESS Phrases” in SQL Data Types and Literals.

    the Lempel-Ziv algorithm

    http://zlib.net.

    comparisons between the different Teradata-supplied compression functions and guidelines for choosing a compression function suitable for your needs

    Database Administration.