Where does the maximum length of 255 come from for CHAR fields?

I mean, 255 doesn't look very natural in the context of computer science.

I suppose this is related to 256, which makes sense in the same context, but I'm wondering how to do this.

+3
source share
2 answers

one byte = 8 bits. 2 ^ 8 == 256 different values, but you must handle 0, so the range is 0-255.

+4
source

According to the documentation: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

CHAR (M) M × w , 0 <= M <= 255, w - , VARCHAR (M), VARBINARY (M) L + 1 , 0 - 255 , L + 2 , 255 .

CHAR - - , , ; , 1 .

VARCHAR , , , , . 255 1 , 65533 2 .

+1

Source: https://habr.com/ru/post/1791169/


All Articles