Jump to content

Changing Field Types

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
BASHERS33

BASHERS33

    Programmer

  • Members
  • PipPipPipPip
  • 198 posts
In mysql if I change a field type, which changes would ruin the data? I assume varchar to int would eliminate the data even if it is numerical. I'm trying to think what I ened to do because I need to change a lot of fields either from varchar to int or from int to varchar and I have a lot of rows with values. I guess I should make temporary fields to keep data in while I change the others.

I assume changing within the same field type would cause no problems? Such as if I change from int to small int, as long as the value was not more than the small int limit it would remain in tact?

I can test this, but I am busy right now so figured I would ask inc ase when I get back someone has answered.

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,298 posts
I think mysql tries to convert if possible. the other way around keeps the data at least.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
You could just make a temp database - convert all the varchars to int in php and see if it works - drop the other table rename the temp one