Why historically do people use 255 not 256 for database field magnitudes?

前端 未结 12 731
北荒
北荒 2020-12-07 07:17

You often see database fields set to have a magnitude of 255 characters, what is the traditional / historic reason why? I assume it\'s something to do with paging / memory l

12条回答
  •  醉梦人生
    2020-12-07 08:17

    I think this might answer your question. Looks like it was the max limit of varchar in earlier systems. I took it off another stackoverflow question.

    It's hard to know what the longest postal address is, of course, which is why many people choose a long VARCHAR that is certainly longer than any address. And 255 is customary because it may have been the maximum length of a VARCHAR in some databases in the dawn of time (as well as PostgreSQL until more recently).

    Are there disadvantages to using a generic varchar(255) for all text-based fields?

提交回复
热议问题