top of page
![](https://static.wixstatic.com/media/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg/v1/fill/w_288,h_162,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg)
Syntax:
COMPRESS(string_to_compress)
Compresses a string and returns the result as a binary string. This
function requires MySQL 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().
URL: https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html
Example
mysql> SELECT LENGTH(COMPRESS(REPEAT('a',1000)));
-> 21
mysql> SELECT LENGTH(COMPRESS(''));
-> 0
mysql> SELECT LENGTH(COMPRESS('a'));
-> 13
mysql> SELECT LENGTH(COMPRESS(REPEAT('a',16)));
-> 15
bottom of page