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
该文章对您有帮助吗?