1

I have imported a csv file into the MySQL database and the DECIMAL(3,2) field is rounded.

In the csv file there are numbers between 0 and 1 (for example: 0,3).

Hence I thought the definition DECIMAL(3,2) should be good enough if I wanted to avoid rounding. But 0,3 is rounded to 0 and I cannot explain why.

Any suggestions?

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
user7335295
  • 401
  • 2
  • 7
  • 31
  • Please show some actual lines from your raw CSV file. `DECIMAL(3,2)` means three total digits of precision, two of which lie to the rights of the decimal point. This would explain why a number like `100.1` is having its decimal data truncated, but it doesn't seem to explain your observations. – Tim Biegeleisen Apr 11 '17 at 07:09

1 Answers1

1

Decimal / floating point numbers must be in the format

0.3

MySQL does not recognize , as a floating point character.

I think your number 0,6 would also result in 0 because it is not rounded but truncated.

Please see also Change decimal separator in MySQL

Community
  • 1
  • 1
Daniel W.
  • 31,164
  • 13
  • 93
  • 151