My favorites | Sign in
Project Home Downloads Wiki Issues Source
Dump and restore float and double columns without loss of precision
Updated Feb 4, 2010 by


Math is hard. Floating point math is even harder.

Alas, MySQL has changed things in MySQL 5.0 that make lossless conversions impossible. See Bug36829 for details. This will not be fixed until 5.1.


To use this feature, invoke mysqldump with the --lossless-fp option. When this is used, columns with type float and double are converted to a decimal string with 17 digits of precision. This is done because conversions from double to decimal and then back to double are lossless (the initial double value is equal to the final double value) when the double to decimal conversion generates 17 digits of precision. This is generally true. There are some values for float and double for which this is not true (subnormal).

mysqldump --lossless-fp my_database my_table > my_table.dump
Comment by, Sep 25, 2007

which version of mysql? does not work here :-(

Sign in to add a comment
Powered by Google Project Hosting