4

In my java web application, I am inserting some records into MySql db. I have a column name 'value' whose Field type is float. When I insert the following value 76.8653846153846 into db, it gives exception of Data truncated for column 'value' at row 1. I changed field type to Double but same message. Any idea?

Field description:

enter image description here

Khawar Raza
  • 15,870
  • 24
  • 70
  • 127
  • 1
    What is the field description in the table where you are trying to insert? – Sashi Kant Jun 21 '12 at 15:26
  • Possible duplicate of [error 1265. Data truncated for column when trying to load data from txt file](http://stackoverflow.com/questions/14764080/error-1265-data-truncated-for-column-when-trying-to-load-data-from-txt-file) – Celik Apr 05 '17 at 13:09

2 Answers2

13

As per the documentation you must define your number type with the level of precision you require.

for your number 76.8653846153846 use

FLOAT(10,13)

The 13 being large enough to handle your .8653846153846

[Edit]

to alter your existing table execute this command substituting your table and column name for mytable and mycolumn respectively

ALTER TABLE mytable MODIFY mycolumn FLOAT(10,13)
Brad
  • 15,186
  • 11
  • 60
  • 74
  • How to set that? I changed Length/Values value to (10,13) next type column but it generates '#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near' error. – Khawar Raza Jun 21 '12 at 15:36
2

This comes from the database engine where the declared field's description in the table is not big enough to insert the complete data

Sashi Kant
  • 13,277
  • 9
  • 44
  • 71