MySQL storing negative and positive decimals
Posted
by Shishant
on Stack Overflow
See other posts from Stack Overflow
or by Shishant
Published on 2010-03-24T19:43:20Z
Indexed on
2010/03/24
19:53 UTC
Read the original article
Hit count: 291
mysql
Hello,
I want to be able to store -11.99
and +11.99
kind of values in mysql db I am thinking of decimals instead of varchar.
But reading mysql site I found out that its incompatible with older versions of mysql
As a result of the change from string to numeric format for DECIMAL storage, DECIMAL columns no longer store a leading + or - character or leading 0 digits. Before MySQL 5.0.3, if you inserted +0003.1 into a DECIMAL(5,1) column, it was stored as +0003.1. As of MySQL 5.0.3, it is stored as 3.1. For negative numbers, a literal - character is no longer stored. Applications that rely on the older behavior must be modified to account for this change.
So what should be the data type, If I have to give up varchar and make it compatible with older versions too?
© Stack Overflow or respective owner