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?
I can't seem to get the syntax right.
Thank you very much.
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:sqlfiddle demo
Just
ALTER TABLE
with theMODIFY
command:This would allow for 2 decimals and 2 full numbers (up to
99.99
). If you want 4 full numbers, use6,2
instead (which would allow up to9999.99
).use CHANGE
an example
example: