Question

Possible Duplicate:
Common mySQL fields and their appropriate data types
What are the recommended database column sizes for names?

I am looking for what would be the most correct field type and size to store email address into a mysql table.

I was initially considering varchar 255 but I think 255 might be too much or even too little what is the average size where I would be able to catch all kinda of valid email address ?

Was it helpful?

Solution

According to RFC 5321, forward and reverse path can be up to 256 chars long, so the email address can be up to 254 characters long. You're safe with using 255 chars.

OTHER TIPS

RFC5321 and RFC5322, the relevant standards for SMTP, specify that an address consists of a local part and a domain. They further state that the maximum sizes for those are respectively 64 and 253 octets, though there's a further 256-octet limit imposed by the forward and reverse paths, including the punctuation (so 254 in reality).

So that should be all that you need for that.

standard in any enterprise web application is varchar with 255 length

  varchar(255)

Using VARCHAR 255 is probably the best idea here - there is nothing lost in giving few more bytes for each email address. 255 is also large enough to avoid cutting any sane email address.

What is the maximum length of a valid email address?

you should use varchar field,
which make the size does not matter (assuming you are not building an index on it)

Well varchar (255) is a standard for me. And i think it is good approach to store emails.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top