I've been searching for what the length in the tinyint
declaration means (e.g. tinyint(5)
). And the answers seem to be that it should just be a rule for how MySQL displays the data. But in my case there seems to be no change whichever length i use, or i just heavily misunderstood what they meant.
For example, setting the length to be shorter than the length of the number i store, i thought maybe it would crop it, but it didn't:
MariaDB [test]> describe test;
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| hello | tinyint(1) | NO | | NULL | |
+-------+------------+------+-----+---------+-------+
1 row in set (0.002 sec)
MariaDB [test]> select * from test;
+-------+
| hello |
+-------+
| 20 |
+-------+
1 row in set (0.000 sec)
Then i changed the length to be longer than the length of the number, expected it to be padded to left with zeroes, but again it wasn't:
MariaDB [test]> describe test;
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| hello | tinyint(3) | NO | | NULL | |
+-------+------------+------+-----+---------+-------+
1 row in set (0.002 sec)
MariaDB [test]> select * from test;
+-------+
| hello |
+-------+
| 20 |
+-------+
1 row in set (0.001 sec)
The version i am using is: 5.5.5-10.3.25-MariaDB-0ubuntu
.
How can i see where this length declaration makes any difference?