MySQL | COMPRESS( ) Function Last Updated : 30 Nov, 2022 Comments Improve Suggest changes Like Article Like Report The MySQL COMPRESS() function is used for the compression of a string. The value returned by the COMPRESS() function is a binary string. The COMPRESS() function stores non-empty strings as a four-byte length of the uncompressed string, which is then followed by the compressed string. If the string ends with space, a "." character is added to the string. Also, it should be noted that empty strings are stored as empty strings. The COMPRESS() function accepts one parameter which is the string to be compressed. Syntax: COMPRESS(string_to_compress) Parameters Used: string_to_compress - It is used to specify the plain text string that is to be compressed. Return Value: The COMPRESS function in MySQL returns a compressed string. Supported Versions of MySQL: MySQL 5.7MySQL 5.6MySQL 5.5MySQL 5.1MySQL 5.0MySQL 4.1 Example-1: Implementing COMPRESS function on a string. SELECT COMPRESS('geeksforgeeks'); Example-2: Implementing COMPRESS function on a string which has a combination of characters and integers. SELECT COMPRESS('geeksforgeeks123'); Output: \0\0\0x?KOM-?N?/JOM?.642\06?? Example-3: Implementing COMPRESS function on a string and returning the length of the string after compression. SELECT COMPRESS('geeksforgeeks'), LENGTH(COMPRESS('geeksforgeeks')); Output: \0\0\0x?KOM?.N?/J?\0%?f 22 Example-4: Implementing COMPRESS function on a NULL string and returning the length of the string after compression. SELECT COMPRESS(NULL), LENGTH(COMPRESS(NULL)); Output: NULL NULL Comment More infoAdvertise with us Next Article MySQL | COMPRESS( ) Function S Shubrodeep Banerjee Follow Improve Article Tags : SQL mysql SQLmysql Similar Reads MySQL COALESCE() Function The MySQL COALESCE() function returns the first non-null value in a list of expressions. COALESCE function in MySQLThe COALESCE function in MySQL is used to get the first non-null value from a list of expressions. If all the values in the list are evaluated to NULL, then the COALESCE() function retu 2 min read MySQL | CONV( ) Function The MySQL CONV() function is used for converting a number from one numeric base system to another. The value returned by the CONV() function is in the form of a string value. It accepts three parameters which are the value to be converted, the current numeric base system and the numeric base system 2 min read MySQL | CAST( ) Function The MySQL CAST() function is used for converting a value from one datatype to another specific datatype. The CAST() function accepts two parameters which are the value to be converted and the datatype to which the value needs to be converted. The datatypes in which a given value can be converted are 3 min read MySQL | CONVERT( ) Function The MySQL CONVERT() function is used for converting a value from one datatype to a different datatype. The MySQL CONVERT() function is also used for converting a value from one character set to another character set. It accepts two parameters which are the input value and the type to be converted in 2 min read PLSQL | COMPOSE Function The string in PL/SQL is actually a sequence of characters with an optional size specification. The characters could be numeric, letters, blank, special characters or a combination of all. The Compose Function in PLSQL is used to return a Unicode string. The unistring values that can be combined with 1 min read Like