Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql Data truncated for column 'value' at row 1

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

like image 620
Khawar Raza Avatar asked Dec 06 '22 13:12

Khawar Raza


2 Answers

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)
like image 57
Brad Avatar answered Dec 09 '22 04:12

Brad


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

like image 23
Sashi Kant Avatar answered Dec 09 '22 02:12

Sashi Kant