Quoting of decimal values
I am storing a running total in a Decimal(10,2) field and adding to it as items are processed.
update foo set bar = bar + '3.15'
About 20% of the times a warning is issued "Data trun开发者_JAVA百科cated for column 'bar' at row 4"
This warning is never issued if the update value is not quoted. Should decimal values be quoted?
Of course not.
Integers and floats are not strings and should never be quoted. Only MySQL even allows quotes around them.
Is it possible that the value you add exceeds the limits of Decimal(10,2)
?
E.g.
update foo set bar = bar + '3.149999'
would cause a 'Data truncated' warning since the field can only store 2 digits to the right of the decimal point (not 6).
No, The decimal values are specified as is. If you quote them it will interpret as a varchar.
No! Quotes are used for strings only, like text, char, varchar, etc
精彩评论