我正在设计一个数据库表,问自己这个问题:名字字段应该多长?

谁有最常见的字段(如名字、姓氏和电子邮件地址)的合理长度的列表?


当前回答

这些可能对某人有用;

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            |                                 |
+------------+---------------+---------------------------------+

编辑:增加了一些间距

是varchar,对吧?所以不管你用50个还是25个,为了安全起见,最好用50个,我认为我见过的最长的是19个左右。姓更长

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/

我想说的是,宁可走偏高的那条路。因为您可能会使用varchar,所以您允许的任何额外空间实际上都不会占用任何额外空间,除非有人需要它。我会说,对于名字(名或名),至少要有50个字符,对于电子邮件地址,至少要有128个字符。有一些很长的电子邮件地址。

我喜欢做的另一件事是访问Lipsum.com,让它生成一些文本。这样,您就可以很好地了解100个字节是什么样子。