Search code examples
mysqlsqlsqlyog

Conversion from Longtext to decimal(17,4)


I have been looking online for its soloution, but couldn't find a way to do it. I have a table named as temp as an example:

incassoid  productid  productamount  amount    
---------  ---------  -------------  -------  
    1          1      50.00          50.0000                  
    2          1      40.00          40.0000                    
    3          1      50.00          50.0000    

where the type of productamount is longtext, I want to convert into Decimal(17,4), So far I have tried:

ALTER TABLE temp ALTER COLUMN productamount Decimal(17,4);

But it gives me an error:

 Error Code: 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(17,4)' at line 1

I dont know what goes wrong, can some one please help in this.....

Thanks


Solution

  • Use MODIFY keyword for the MySQL

    ALTER TABLE temp MODIFY COLUMN productamount Decimal(17,4);