COMPRESS()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Compresses the given string and returns the binary string result.
USAGE
COMPRESS(string)
Argument Name | Description |
---|---|
| The string to compress |
DETAILS
COMPRESS()
is a compression function that compresses a string and returns a binary value.
An empty input string results in an empty output value.
The binary value for a non-empty string starts with a 4-byte length of the input (LSB
) followed by the compressed data.
A NULL
is returned if the argument is NULL
.
EXAMPLES
SELECT HEX(COMPRESS('Now is the time!'));
+----------------------------------------------------------+
| HEX(COMPRESS('Now is the time!')) |
+----------------------------------------------------------+
| 10000000789CF3CB2F57C82C5628C9485528C9CC4D5504002FA10582 |
+----------------------------------------------------------+
SELECT LENGTH(COMPRESS('abc'));
+-------------------------+
| LENGTH(COMPRESS('abc')) |
+-------------------------+
| 15 |
+-------------------------+
SELECT LENGTH(COMPRESS(REPEAT('a', 1000)));
+-------------------------------------+
| LENGTH(COMPRESS(REPEAT('a', 1000))) |
+-------------------------------------+
| 21 |
+-------------------------------------+