Length of EmailAddress field in database

Possible Duplicate:
What is the optimal length for an email address in the database?

What would you put in the email address length field?

In the db I care that we have nvarchar (60), but that seems arbitrary.

Is there a maximum length I can allow or the length of email addresses is unlimited?

EDIT this is cheating What is the optimal length for an email address in the database?

please close

+2


source to share


4 answers


The maximum length for an email address is 254 characters.

Each email address has two parts. The local part that appears before the @ sign and the domain part that follows. In " user@example.com ", the local part is "user" and the domain part is "example.com".

The local part cannot exceed 64 characters and the domain part cannot exceed 255 characters.



The combined length of local domains + @ + email addresses must not exceed 254 characters. As described in RFC3696 Errata ID 1690 .

What is the optimal length for an email address in the database?

+15


source


This wikipedia article contains useful background information.



You should be safe with 256 characters.

+4


source


Is it for storing the content of the entire email in a database? In this case, I would use the database type text

rather than char

or varchar

, since letters can be of arbitrary length.

+2


source


Something like 64 or more, but make sure you always truncate user input (up to 64) anyway. You don't want to miss important information (user record) just because the email was larger than you expected.

+1


source







All Articles