COMPRESS
Sintassi
COMPRESS(stringa_da_comprimere)
Spiegazione
Comprime una stringa e restituisce il risultato come stringa binaria. Questa funzione richiede che MariaDB sia stata compilata con una libreria di compressione, come zlib. Altrimenti il valore restituito sarà sempre NULL
. La stringa compressa potrà essere decompressa con UNCOMPRESS()
.
Esempi
MariaDB [(none)]> SELECT LENGTH(COMPRESS(REPEAT('a',1000))); +------------------------------------+ | LENGTH(COMPRESS(REPEAT('a',1000))) | +------------------------------------+ | 21 | +------------------------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SELECT LENGTH(COMPRESS('')); +----------------------+ | LENGTH(COMPRESS('')) | +----------------------+ | 0 | +----------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SELECT LENGTH(COMPRESS('a')); +-----------------------+ | LENGTH(COMPRESS('a')) | +-----------------------+ | 13 | +-----------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SELECT LENGTH(COMPRESS(REPEAT('a',16))); +----------------------------------+ | LENGTH(COMPRESS(REPEAT('a',16))) | +----------------------------------+ | 15 | +----------------------------------+ 1 row in set (0.00 sec) MariaDB [(none)]>
Commenti
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
Compress don't work for me, I obtain the error: Incorrect string value: '\x9C+\xC8,(\xC8...' for column
the script is: update notifica set dom = compress('pippo') where id_notifica = 319798;
where column "dom" is mediumtext and table is UTF8, I tried also with utf8mb4 but nothing, compress don't work. thanks
Add information, the SELECT compress(dom) FROM notifica; works fine. thanks