I noticed some interesting thing
When I create some field lets say of int type its size supposed to be 4 bytes. Like this
Alter table tbl_countries add country_id INT
Then I looked into the table using MySQL-Front and was amaized to find out that the field has a length of 11. From where is the addon of 7 bytes ?
If i force the size and change it to 4 it works perfectly. And the maximum value that can be in both cases is 4294967295 (unsigned) but why mysql adds those 7 bytes?
By the way the same thing is happening with tinyint which by default comes with size of 4 instead of 1.
If anyone can explain this I would be thankful.
My second question is about alter table
I want to add pack_keys=1 to some of my read only accessed tables which have numeric indexes, what is the correct alter table statement to add this option.
I think 11 means 11 positions in the number, which is equal to 4 bytes (max value 2147483648, and the 11th position is for "-", if negative)
hmm probably so but then if I change this possition to 4 I still can enter maximum value for integer. Then for what those positions used ?
"INT[(M)] [UNSIGNED] [ZEROFILL]
A normal-size integer.
... M Indicates the maximum display size."
Don't know why you would want to use 4 bytes, but only display numbers up to, for example, 9999?