If you want to remove the spaces from the middle of the string too, you can use the replaceAll method of String class with a regex like \s to replace all the space characters with anything that you like. This method would be a little slow if you want to update all the records.
You should try a bulk update query specific to your database to achieve that...