我正在设计一个数据库表,问自己这个问题:名字字段应该多长?
谁有最常见的字段(如名字、姓氏和电子邮件地址)的合理长度的列表?
我正在设计一个数据库表,问自己这个问题:名字字段应该多长?
谁有最常见的字段(如名字、姓氏和电子邮件地址)的合理长度的列表?
当前回答
是varchar,对吧?所以不管你用50个还是25个,为了安全起见,最好用50个,我认为我见过的最长的是19个左右。姓更长
其他回答
我通常会选择:
名字:30个字符 姓氏:30个字符 电子邮件:50个字符 地址:200个字符
如果我担心名称字段太长,我有时也会将名称字段设置为50,因为现在存储空间很少成为问题。
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应用程序,性能不是问题。不要过早地优化。
是varchar,对吧?所以不管你用50个还是25个,为了安全起见,最好用50个,我认为我见过的最长的是19个左右。姓更长
这些可能对某人有用;
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/
+------------+---------------+---------------------------------+
| Field | Length (Char) | Description |
+------------+---------------+---------------------------------+
|firstname | 35 | |
|lastname | 35 | |
|email | 255 | |
|url | 60+ | According to server and browser |
|city | 45 | |
|address | 90 | |
+------------+---------------+---------------------------------+
编辑:增加了一些间距