dcsimg
LinkedIn
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Intermediate
Jan 10, 2020

Understanding UNCOMPRESSED_LENGTH in MySQL

In MySQL, once we use the COMPRESS method to compress a particular text, the LENGTH of the resultant text is not the same as that of the original text.

However, using UNCOMPRESSED_LENGTH method on the compressed text results in the exact length of the original text, even though the text is currently compressed.

Example:

SELECT UNCOMPRESSED_LENGTH(COMPRESS('MyName'))

+-----------------------------------------+
| UNCOMPRESSED_LENGTH(COMPRESS('MyName')) |
+-----------------------------------------+
|                                      6  | 
+-----------------------------------------+

Now, use the below query

SELECT LENGTH(COMPRESS('MyName'))

+----------------------------+
| LENGTH(COMPRESS('MyName')) |
+----------------------------+
|                         18 | 
+----------------------------+

This indicates the different values in length using the two different LENGTH methods.

Sridhar MS
 
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date