When we use an argument length with numerical data types, as far as I know this specifies the display width.
I tried the following:
mysql> create table boolean_test (var1 boolean, var2 tinyint);
Query OK, 0 rows affected (0.10 sec)
mysql> show create table boolean_test;
+--------------+-------------------------
| Table | Create Table
+--------------+-------------------------
| boolean_test | CREATE TABLE `boolean_test` (
`var1` tinyint(1) DEFAULT NULL,
`var2` tinyint(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+--------------+---------------------------
1 row in set (0.00 sec)
First of all tinyint is a 1 byte value. So what is the meaning of tinyint(4)? There can not be 4 digits.
mysql> insert into boolean_test values(101,112);
Query OK, 1 row affected (0.03 sec)
mysql> select * from boolean_test;
+------+------+
| var1 | var2 |
+------+------+
| 10 | 112 |
| 101 | 112 |
+------+------+
2 rows in set (0.00 sec)
I see that in tinyint I stored a 10 and 101 and I could get back these values despite that it is defined as tinyint(1).
Shouldn't I see a 1 for var1? I.e. just 1 display digits?