MySQL - How do I update the decimal column to allow more digits?

ValleyDigital picture ValleyDigital · Nov 4, 2013 · Viewed 45.3k times · Source

I'm a beginner in MySQL, and I accidentally created a table with a column named

(price decimal(2,2));

It needs to be decimal(4,2) to allow 4 digits. Since I've already created it, what is the easiest way to update that decimal value to decimal(4,2)? Or do I need to drop that column completely, and re-create it with the correct numbers?

Answer

Eduardo Dennis picture Eduardo Dennis · Nov 4, 2013
ALTER TABLE mytable MODIFY COLUMN mycolumn newtype

example:

ALTER TABLE YourTableNameHere MODIFY COLUMN YourColumnNameHere decimal(4,2)