MySQL storing negative and positive decimals
- by Shishant
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?