Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Acceptable field type and size for email address? [duplicate]

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 ?

like image 474
Guapo Avatar asked Nov 23 '11 12:11

Guapo


People also ask

How big should email field be?

Most people believe it to be 320 characters (64 characters for the username + 255 characters for the domain + 1 character for the @ symbol). Other sources suggest 129 (64 + 1 + 64) or 384 (128+1+255, assuming the username doubles in length in the future).

What should be the data type of an email address?

you can use varchar as your data type for email column as emails are usually composed of letters, numbers and special characters. Show activity on this post. The right value of data lenght for the email field is database-agnostic.

How many bytes can you store an email address?

TLDR Answer. Use a VARCHAR(256) to store the 256 character maximum entailed in current, prevailing RFC Internet standards.

What is the data type for email in MySQL?

use the varchar(50) datatype.


2 Answers

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.

like image 189
socha23 Avatar answered Oct 08 '22 03:10

socha23


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.

like image 24
paxdiablo Avatar answered Oct 08 '22 04:10

paxdiablo