Open In App

MySQL | UNCOMPRESSED_LENGTH( ) Function

Last Updated : 17 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The MySQL UNCOMPRESSED_LENGTH() function is used for returning the length of the string before it had been compressed. It is used on a string that has been compressed using the COMPRESSED() function. 

The MySQL UNCOMPRESSED_LENGTH() function returns NULL if the compressed string is a NULL string. It accepts one parameter which is the compressed string whose length needs to be calculated. 

Syntax: 

UNCOMPRESSED_LENGTH(compressed_string);

Parameters Used: 
compressed_string – It is used to specify the compressed string whose length needs to be calculated. 

Return Value: 
The UNCOMPRESSED_LENGTH() function in MySQL returns the length of a compressed string. 

Supported Versions of MySQL: 

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1

Example-1: Implementing UNCOMPRESSED_LENGTH() function on a string. 
 

SELECT  
UNCOMPRESSED_LENGTH(COMPRESS('geeksforgeeks')); 

Output: 

13 

Example-2: Implementing UNCOMPRESSED_LENGTH() function on a string which has a combination of characters and integers. 

SELECT 
UNCOMPRESSED_LENGTH(COMPRESS('geeksforgeeks123')); 

Output: 

16 

Example-3: Implementing UNCOMPRESSED_LENGTH() function on a NULL string and returns the length of the string after compression. 

SELECT
UNCOMPRESSED_LENGTH(COMPRESS(NULL)); 

Output: 

NULL 

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads