What does the number in parenthesis really mean?

后端 未结 2 1703
醉酒成梦
醉酒成梦 2020-12-09 02:20

I always thought that the number in the parenthesis represented the field length?

However, I understand that is not always the case. Maybe it\'s a MySQL issu

2条回答
  •  情话喂你
    2020-12-09 02:37

    That's the case for field types like vchar, but for numbers it represents the number of bytes which it uses to represent the number. An integer of two bytes means you can hold a number 2^16 - 1 (8 bits in a byte, so 16 total). If it's age, I figure you ought to be safe with two bytes. ;)

提交回复
热议问题