List of standard lengths for database fields

后端 未结 13 1756
日久生厌
日久生厌 2020-12-02 03:30

I\'m designing a database table and once again asking myself the same stupid question: How long should the firstname field be?

Does anyone have a li

相关标签:
13条回答
  • 2020-12-02 03:47

    it is varchar right? So it then doesn't matter if you use 50 or 25, better be safe and use 50, that said I believe the longest I have seen is about 19 or so. Last names are longer

    0 讨论(0)
  • I wanted to find the same and the UK Government Data Standards mentioned in the accepted answer sounded ideal. However none of these seemed to exist any more - after an extended search I found it in an archive here: http://webarchive.nationalarchives.gov.uk/+/http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards.aspx. Need to download the zip, extract it and then open default.htm in the html folder.

    0 讨论(0)
  • 2020-12-02 03:50

    I usually go with:

    Firstname: 30 chars
    Lastname: 30 chars
    Email: 50 chars
    Address: 200 chars

    If I am concerned about long fields for the names, I might sometimes go with 50 for the name fields too, since storage space is rarely an issue these days.

    0 讨论(0)
  • 2020-12-02 03:54

    These might be useful to someone;

    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/

    0 讨论(0)
  • 2020-12-02 03:59

    I just queried my database with millions of customers in the USA.

    • The maximum first name length was 46. I go with 50. (Of course, only 500 of those were over 25, and they were all cases where data imports resulted in extra junk winding up in that field.)

    • Last name was similar to first name.

    • Email addresses maxed out at 62 characters. Most of the longer ones were actually lists of email addresses separated by semicolons.

    • Street address maxes out at 95 characters. The long ones were all valid.

    • Max city length was 35.

    This should be a decent statistical spread for people in the US. If you have localization to consider, the numbers could vary significantly.

    0 讨论(0)
  • 2020-12-02 04:00
    +------------+---------------+---------------------------------+
    |   Field    | Length (Char) |           Description           |
    +------------+---------------+---------------------------------+
    |firstname   | 35            |                                 |
    |lastname    | 35            |                                 |
    |email       | 255           |                                 |
    |url         | 60+           | According to server and browser |
    |city        | 45            |                                 |
    |address     | 90            |                                 |
    +------------+---------------+---------------------------------+
    

    Edit: Added some spacing

    0 讨论(0)
提交回复
热议问题