I just created one role table and i defined role_id tinyint(1), even though i was able to store 99, 200 max upto 255 as tinyint limit for unsigned. so then what is the meaning of passing this size in data-types?
when read little that, it is about the display width, but when i fetch result on my php page, it displays as they are stored in the table.
Any mentor, can you please guide me to clear it?
from 10.1.1. Numeric Type Overview:
So
tinyint(M), ortinyint(1)in your case, means that any value stored inrole_idwill be chopped to a length of one byte when being displayed by MySQL. Similarlytinyint(3)would case a one digit integer to be padded with two spaces. You can also usetinyint(3) zerofillto pad with0s instead, but it has the side-effect of making yourtinyints unsigned.However, regardless how you specify your
tinyints they will be stored internally as an integer in the range[-128,127](signed) or[0,255](unsigned), and so that’s the value PHP will receive when querying your database.You can use mysql_field_len and substr to limit the display width similarly with PHP.