Jump to content

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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.