MySQL - How do I update the decimal column to allow more digits?
It's not a matter of 'UPDATE' it's a matter of changing your table's structure. For that, use ALTER TABLE with MODIFY
clause:
ALTER TABLE YourTableName MODIFY COLUMN price DECIMAL(4,2);
sqlfiddle demo
ALTER TABLE mytable MODIFY COLUMN mycolumn newtype
example:
ALTER TABLE YourTableNameHere MODIFY COLUMN YourColumnNameHere decimal(4,2)
Just ALTER TABLE
with the MODIFY
command:
ALTER TABLE `table` MODIFY `price` DECIMAL(4,2)
This would allow for 2 decimals and 2 full numbers (up to 99.99
). If you want 4 full numbers, use 6,2
instead (which would allow up to 9999.99
).
use CHANGE
ALTER TABLE table_name CHANGE OLD_COLUMN_NAME OLD_COLUMN_NAME datatype;
an example
ALTER TABLE table_name CHANGE price price decimal(4,2);