This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

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)]> 
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.