Acceptable field type and size for email address?

MysqlSizeEmail AddressFieldtype

Mysql Problem Overview


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

Mysql Solutions


Solution 1 - Mysql

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.

Solution 2 - Mysql

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.

Solution 3 - Mysql

standard in any enterprise web application is varchar with 255 length

  varchar(255)

Solution 4 - Mysql

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.

Solution 5 - Mysql

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

Solution 6 - Mysql

https://stackoverflow.com/questions/386294/maximum-length-of-a-valid-email-id

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGuapoView Question on Stackoverflow
Solution 1 - Mysqlsocha23View Answer on Stackoverflow
Solution 2 - MysqlpaxdiabloView Answer on Stackoverflow
Solution 3 - MysqlMithun SasidharanView Answer on Stackoverflow
Solution 4 - MysqlJukka DahlbomView Answer on Stackoverflow
Solution 5 - Mysqlnoobie-phpView Answer on Stackoverflow
Solution 6 - MysqlajrealView Answer on Stackoverflow