Forum Moderators: open

Message Too Old, No Replies

What MySQL cell types should I use to for names, ips and emails?

TINYTEXT? or maybe CHARVAR?

         

Jeremy_H

4:03 am on Jul 12, 2006 (gmt 0)

10+ Year Member



I would like to store several values into a MySQL table, and I'm wondering how best to do it.

Right now I have the following stored as "TINYTEXT":
An IP Address
A Name
An Email Address

This seems wasteful, but I tried creating them as CHAR but it requires I put in a length. Once I put in a length, then it changes it to CHARVAR. I'm hesitant to set them as CHARVAR since they can be of any length.

Should I look to store them as something else?

Thanks for any help.

topr8

7:25 am on Jul 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if you use CHAR ensure you trim the data when you call it as the "empty" space will still be included in the return.

i generally use VARCHAR

if you are searching on those fields technically a CHAR will be found quicker, but a VARCHAR will take less space, you need to choose between teh two.

lbft

5:22 pm on Jul 15, 2006 (gmt 0)

10+ Year Member



There's little speed difference between accessing char and varchar columns in any reasonably modern database, so I wouldn't be too concerned about that.

MySQL will let you specify an upper limit on the length of a varchar column, although there's also an implicit limit (255 bytes in versions older than 5.0.3, or up to 65,532 bytes in 5.0.3 or later.)