Alter syntax MySQL conversion varchar to decimal

I have imported a large excel file into a MySQL table
I want to change a varchar field to a decimal field
I thought the syntax would be
ALTER TABLE tablename ALTER COLUMN columnname DECIMAL (10,2)

but I keep getting a syntax error in SQL
Is such a change permitted or do I have the syntax incorrect
Thanks
Can someone help?
jxllAsked:
Who is Participating?
 
jxllConnect With a Mentor Author Commented:
Thanks
I get a syntax error and no conversion occurs

[SQL] Alter table elaboratebirth2006v6 alter column Australia_M Decimal(10,2)

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Decimal(10,2)' at line 1
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>Is such a change permitted
it is permitted, BUT it will fail if at least 1 row's date for the column cannot be converted appropriately.

please show the EXACT error you get.
0
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
I found it.. it must be MODIFY and not ALTER:


Alter table elaboratebirth2006v6 modify column Australia_M decimal(10,2)

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.