电子邮件地址可接受的字段类型和大小?
我正在寻找将电子邮件地址存储到 mysql 表中的最正确的字段类型和大小。
我最初考虑使用 varchar 255,但我认为 255 可能太多甚至太小,我能够捕获所有有效电子邮件地址的平均大小是多少?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
根据 RFC 5321,正向和反向路径的长度最多可达 256 个字符,因此电子邮件地址的长度最多可达 254 个字符。使用 255 个字符是安全的。
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.
RFC5321 和 RFC5322,SMTP的相关标准,规定一个地址由本地部分和域。他们进一步指出,这些最大大小分别为 64 和 253 个八位位组,尽管前向和反向路径(包括标点符号)还施加了 256 个八位位组的限制(实际上是 254 个八位位组)。
这应该就是您所需要的一切。
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.
任何企业 Web 应用程序中的标准都是长度为 255 的 varchar
standard in any enterprise web application is varchar with 255 length
使用 VARCHAR 255 可能是最好的主意 - 为每个电子邮件地址提供更多字节不会造成任何损失。 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.
varchar (255) 对我来说是一个标准。我认为这是存储电子邮件的好方法。
Well varchar (255) is a standard for me. And i think it is good approach to store emails.
有效电子邮件地址的最大长度是多少?
您应该使用varchar 字段,
这使得大小并不重要(假设您没有在其上构建索引)
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)