MySQL 电子邮件地址可接受的字段类型和大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8242567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Acceptable field type and size for email address?
提问by Guapo
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.
我正在寻找将电子邮件地址存储到 mysql 表中的最正确的字段类型和大小。
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 ?
我最初考虑使用 varchar 255,但我认为 255 可能太多或什至太少,我能够捕获所有有效电子邮件地址的平均大小是多少?
回答by socha23
回答by paxdiablo
RFC5321and 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).
RFC5321和RFC5322是 SMTP 的相关标准,指定地址由本地部分和域组成。他们进一步指出,它们的最大大小分别为 64 和 253 个八位字节,尽管正向和反向路径还施加了 256 个八位字节的限制,包括标点符号(实际上是 254 个)。
So that should be all that you need for that.
所以这应该就是你所需要的。
回答by Mithun Sasidharan
standard in any enterprise web application is varchar with 255 length
任何企业 Web 应用程序的标准都是长度为 255 的 varchar
varchar(255)
回答by Jukka Dahlbom
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 可能是最好的主意 - 为每个电子邮件地址提供更多字节不会有任何损失。255 也足够大,可以避免删除任何理智的电子邮件地址。
回答by noobie-php
Well varchar (255) is a standard for me. And i think it is good approach to store emails.
那么 varchar (255) 对我来说是一个标准。我认为这是存储电子邮件的好方法。
回答by ajreal
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)
您应该使用 varchar 字段,
这使得大小无关紧要(假设您没有在其上构建索引)