Mysql COMPRESS
From w3cyberlearnings
Contents |
MySQL COMPRESS Function
This function returns a binary string. To uncompressed string uses UNCOMPRESS().
Syntax COMPRESS
- str: string to compress
COMPRESS(str);
Note
Recommend use a VARBINARY OR BLOB to store COMPRESS binary string.
Example 1
mysql> SELECT COMPRESS('excellent leader'); +------------------------------+ | COMPRESS('excellent leader') | +------------------------------+ | � x?K?HN??I?+Q?IMLI-� 6d�R | +------------------------------+ 1 row in set
Example 2
mysql> SELECT LENGTH(COMPRESS('i go')),LENGTH('i go'); +--------------------------+----------------+ | LENGTH(COMPRESS('i go')) | LENGTH('i go') | +--------------------------+----------------+ | 16 | 4 | +--------------------------+----------------+ 1 row in set (0.00 sec)
Example 3
mysql> CREATE TABLE blobtext -> (text blob not null); Query OK, 0 rows affected (0.01 sec) mysql> INSERT blobtext(text) VALUES(COMPRESS('good leader')); Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM blobtext; +-------------------------+ | text | +-------------------------+ | x�K��OQ�IMLI-� �"�7 | +-------------------------+ 1 row in set (0.0