1

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

What would you put as the length of an email address field?

In the db I look after we have nvarchar(60) but this seems arbitrary.

Is there a maximum length I can allow for or are email address lengths unbounded?

EDIT this is a dupe of
What is the optimal length for an email address in a database?

please close

Community
  • 1
  • 1
Johnno Nolan
  • 29,228
  • 19
  • 111
  • 160

4 Answers4

16

The maximum length of an email address is 254 characters.

Every email address is composed of two parts. The local part that comes before the '@' sign, and the domain part that follows it. In "user@example.com", the local part is "user", and the domain part is "example.com".

The local part must not exceed 64 characters and the domain part cannot be longer than 255 characters.

The combined length of the local + @ + domain parts of an email address must not exceed 254 characters. As described in RFC3696 Errata ID 1690.

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

Community
  • 1
  • 1
Iain Hoult
  • 3,889
  • 5
  • 25
  • 39
4

This wikipedia article contains some useful background information.

You should be safe with 256 characters.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
2

Is this for storing the contents of an entire email in the database? In this case I'd use the database type text rather than char or varchar, as emails can be of arbitrary length.

Adamski
  • 54,009
  • 15
  • 113
  • 152
1

Something like 64 or more, but in any case make sure that you always truncate the user input (to 64). You don't want to be missing important information (user entry) just because the email was longer than you expected.

cherouvim
  • 31,725
  • 15
  • 104
  • 153