Name
COMPRESS()
Synopsis
COMPRESS(string
)
This function returns a given string after compressing it. It
requires MySQL to have been compiled with a compression library (e.g.,
zlib
). If it wasn’t, a NULL value will be returned.
This statement is available as of version 4.1 of MySQL. Here is an
example:
UPDATE students_records SET personal_essay = (SELECT COMPRESS(essay) FROM student_applications WHERE applicant_id = '7382') AS derived1 WHERE student_id = '433302000';
If you want to store a value that was compressed with this
function, it’s best to store it in a BLOB
column,
since the results are binary. Use UNCOMPRESS() to
uncompress a string that was compressed with this function.
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.