COMPRESS

更新时间:
复制 MD 格式

Compresses a STRING or BINARY value using the GZIP algorithm and returns the result as a BINARY value.

Syntax

binary compress(string <str>)
binary compress(binary <bin>)

Parameters

Parameter Type Required Description
str STRING Yes The string value to compress.
bin BINARY Yes The binary value to compress.

Return value

Returns a BINARY value. Returns null if the input is null.

Examples

Example 1: Compress the string hello.

-- Return value: =1F=8B=08=00=00=00=00=00=00=03=CBH=CD=C9=C9=07=00=86=A6=106=05=00=00=00
select compress('hello');

Example 2: Compress an empty string.

-- Return value: =1F=8B=08=00=00=00=00=00=00=03=03=00=00=00=00=00=00=00=00=00
select compress('');

Example 3: The parameter is null.

-- Return value: null
select compress(null);

Related functions

Other functions