From: "Steve Buehler" > I am trying to figure something out about the compress function. If I > wanted to compress a field in a column/row and write it back to the table, > how can I do this? Is it possible to do it in one command? I tried: > update `conflicts` set `fname`=(SELECT compress(`fname`) FROM `conflicts` > WHERE `conflict_id`='2') where `conflict_id`='2' >
As you can read at http://dev.mysql.com/doc/mysql/en/string-functions.html you need MySQL 4.1.1 or later that has been compiled with a compression library such as zlib. You can check this by SELECT COMPRESS('an example string to test the compress function'); If this produces NULL than MySQL has not been compiled with a compression library. To 'convert' a whole table all you need to do is: UPDATE `conflicts` SET `fname` = COMPRESS(`fname`); If you do selects in the future you have to use the UNCOMPRESS() function: SELECT UNCOMPRESS(`fname`) AS `fname`, `other_col`, ... FROM `conflicts` WHERE `conflict_id` < 5; As you can imagine it is not efficient to use compress() for very short strings. It is also not advisable to search on a column that is compressed, because that would require an uncompress() on each record before you can do any compare or other operation. It's best used for relatively large text fields which you only use to store information that will never be searched. Regards, Jigal. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]