vendredi 8 juillet 2016

Data truncation when decreasing Decimal Column in MySQL

I'm getting a strange error with MySQL 5.6 during an alter table.

I have a column foo that is a decimal (20,4) and it has one row with the value of 91329132.0000.

The column now is being altered to decimal (13,4) and, for that row in specific, I'm getting data truncation.

Looking at the number it doesn't seem to be large enough to overflow a decimal (13,4) but it is. Once it is updated to 0 (zero) for instance the issue of data truncation stop happening.

Although I have a possible fix I'm looking to understand why this happens so I'm capable of doing a more elegant solution than an update column to 0.

Any help appreciated.

Aucun commentaire:

Enregistrer un commentaire