我正在设计一个数据库表,问自己这个问题:名字字段应该多长?
谁有最常见的字段(如名字、姓氏和电子邮件地址)的合理长度的列表?
我正在设计一个数据库表,问自己这个问题:名字字段应该多长?
谁有最常见的字段(如名字、姓氏和电子邮件地址)的合理长度的列表?
当前回答
W3C推荐:
If designing a form or database that will accept names from people with a variety of backgrounds, you should ask yourself whether you really need to have separate fields for given name and family name. … Bear in mind that names in some cultures can be quite a lot longer than your own. … Avoid limiting the field size for names in your database. In particular, do not assume that a four-character Japanese name in UTF-8 will fit in four bytes – you are likely to actually need 12. https://www.w3.org/International/questions/qa-personal-names
对于数据库字段,VARCHAR(255)是一个安全的默认选择,除非您确实有充分的理由使用其他选项。对于典型的web应用程序,性能不是问题。不要过早地优化。
其他回答
这些可能对某人有用;
youtube max channel length = 20
facebook max name length = 50
twitter max handle length = 15
email max length = 255
http://www.interoadvisory.com/2015/08/6-areas-inside-of-linkedin-with-character-limits/
Just looking though my email archives, there are a number of pretty long "first" names (of course what is meant by first is variable by culture). One example is Krishnamurthy - which is 13 letters long. A good guess might be 20 to 25 letters based on this. Email should be much longer since you might have firstname.lastname@somedomain.com. Also, gmail and some other mail programs allow you to use firstname.lastname+sometag@somedomain.com where "sometag" is anything you want to put there so that you can use it to sort incoming emails. I frequently run into web forms that don't allow me to put in my full email address without considering any tags. So, if you need a fixed email field maybe something like 25.25+15@20.3 in characters for a total of 90 characters (if I did my math right!).
是varchar,对吧?所以不管你用50个还是25个,为了安全起见,最好用50个,我认为我见过的最长的是19个左右。姓更长
我刚刚查询了美国数百万客户的数据库。
名字的最大长度为46。我猜是50个。(当然,其中超过25岁的只有500个,而且都是数据导入导致该领域出现额外垃圾的情况。) 姓与名相似。 电子邮件地址最多62个 字符。大部分是较长的 实际上是电子邮件列表吗 用分号分隔的地址。 街道地址最多95 字符。长点的都是 有效的。 最大城市长度为35。
对于美国人来说,这应该是一个不错的统计分布。如果你需要考虑本土化问题,数值可能会有很大差异。
英国政府数据标准目录详细说明了这类事情的英国标准。 它建议“名”和“姓”各有35个字符,“全名”为70个字符,“电子邮件地址”为255个字符。除此之外…