Thursday, November 19, 2009

How to change varchar field to decimal in mysql

To alter column in mySQL from varchar to DECIMAL I used this syntax.

Alter table my_tbl  modify my_col decimal(6,2);

MySQL uses the Round routines of the host.


On a Windows box

16.125 = 16.13

16.135 = 16.14



On a Linux/Unix box

16.125 = 16.12

16.135 = 16.14

2 comments:

  1. can I add not null at the end of this command.

    ReplyDelete
  2. The solution that you have suggested is nice and works well. I have used it multiple times and it perfectly works. You have made a great blog and shared information on so many useful concept of Oracle database. Keep sharing !
    sap upgrades

    ReplyDelete

Followers