Mysql Data truncation for Valid DECIMAL

decimalMySQL

create table test(id INT, value DECIMAL(25,6));
insert into test values (16, 10e16);
insert into test values (17, 10e17);  -- Works till here
insert into test values (18, 10e18);  -- Fails here. Data truncation: Out of range value for column 'value'
insert into test values (19, 10e19);

How is this possible?

Best Answer

A DECIMAL(25,6) stores 25 digits, 6 of them fractional, i.e. a value up to 9,999,999,999,999,999,999.999999

10e18 is 10,000,000,000,000,000,000.000000