Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Altering datatype in existing table? 1

Status
Not open for further replies.

Tasuki

MIS
Jul 26, 2002
169
US
Hi,

I'm having a little trouble and can't seem to find the correct command to change an existing field's datatype to a different one. Currently the field has datatype "int(10)" and I'd like to change it to "decimal(9, 1)".

If anyone can point me in the right direction to solving this problem. It would be greatly appreciated.

Thank you,

-T
 
alter tableName change old_columnName New_deinfinition

alter tabelName change old_columnName decimal(9,1)

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Thanks for your reply, I typed:

alter tblSample change sample_num decimal(9,1);

And received the following error:

ERROR 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 'tblSample change sample_num decimal(9,1)' at line 1

Would you happen to know what I'm doing wrong?

Thanks again,

-T
 
I think I figured it out...

alter table tblSample change sample_num sample_num decimal(9,1) unique not null default 0;

Seems to work but now I get this error:

ERROR 1062: Duplicate entry '0.0' for key 3

But clearly there is no duplicates in the table... strange.

Hmm...

-T
 
Okay I figured it out, the top Alter command works fine. Thanks for a shove in the right direction.

-T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top