COMPRESS
Syntax
COMPRESS(string_to_compress)
Description
Compresses a string and returns the result as a binary string. This function requires MariaDB to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL
. The compressed string can be uncompressed with UNCOMPRESS().
The have_compress server system variable indicates whether a compression library is present.
Examples
SELECT LENGTH(COMPRESS(REPEAT('a',1000))); +------------------------------------+ | LENGTH(COMPRESS(REPEAT('a',1000))) | +------------------------------------+ | 21 | +------------------------------------+ SELECT LENGTH(COMPRESS('')); +----------------------+ | LENGTH(COMPRESS('')) | +----------------------+ | 0 | +----------------------+ SELECT LENGTH(COMPRESS('a')); +-----------------------+ | LENGTH(COMPRESS('a')) | +-----------------------+ | 13 | +-----------------------+ SELECT LENGTH(COMPRESS(REPEAT('a',16))); +----------------------------------+ | LENGTH(COMPRESS(REPEAT('a',16))) | +----------------------------------+ | 15 | +----------------------------------+
See Also
This page is licensed: GPLv2, originally from fill_help_tables.sql
Last updated
Was this helpful?