im using a v simple database and i have 3 columns A(bigINT 20) , B(bigInt 20) and c(DECIMAL(5,4)) , when i fire the following query i get the below mentioned results :
REPLACE INTO `my_table` SET `A` = 8,`B` = 44,`C` = 14;
i get these values in mysql A =8 , b= 44 and c as 9.9999 ! ?
any ideas as to why is this happening and what can i do to resolved this ?
DECIMAL(5,4)means that the number has at most5digits,4of them after decimal point. So14is simply overflow as it would requireDECIMAL(6,4).It must be cleared that
14is overflow, because as constant precision point decimal it is internally14.0000here (so six digits over five).So if you try to put
14.0000(six digits) inDECIMAL(5,4)(five digits max) -> MySQL chooses value closest to the one you request. Therefore14.0000gets “rounded” to9.9999.To fit
14in your column you can either extend it doDECIMAL(6,4)(to allow more digits in general) or change toDECIMAL(5,3)(which will allow one more digit before decimal point, but loses some precision of course).