Jump to content

Mysql data type and size


warhead2020

Recommended Posts

Hi,

Im quite new to mysql/DB. I have simple question. Lets say I want to create one column 'Number'. Yeah i know, the data type should be int/double. But if i declare it as 'Varchar(100)', is there any effect in term of performance/speed etc etc etc? I know to some ppl it is simple but for me its quite important. Thanx in advance.

Link to comment
https://forums.phpfreaks.com/topic/185600-mysql-data-type-and-size/
Share on other sites

If you are using a string in an arithmetic operation, this is converted to a floating-point number.

 

If you use a string data type to hold numbers and then reference the value as a number it is converted to floating-point or you must cast it back to a number so that comparisons/sorting work, thereby taking up additional processing time on each reference.

 

Edit: Strings are sorted and compared character by character, left-to-right, which means that for example, the string '10' is less than the string '2'

Logically there is no problem to insert number into varchar right?

Actually, it's quite illogical to store a number as anything but a number.

 

But still u can insert number into varchar column right? I jus want to know is there any effect to performance/size etc? Maybe your DB size will be bigger or anything?? just curious...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.