I have a column in MySQL database which is defined as
IsDeleted
tinyint(1) NOT NULL DEFAULT '0'
in a table called MyTable
.
According to the MySQL document here:
M indicates the maximum display width for integer types. The maximum display width is 255. Display width is unrelated to the range of values a type can contain, as described in Section 11.2, “Numeric Types”.
M
in the above paragraph represents the 1
in TINYINT(1)
.
I think this means that when I store the value 23
, which contains 2 digits, inside this column.
UPDATE MyTable SET IsDeleted=23 WHERE id = 1;
I'll see 2
or 3
when I retrieve the value.
But I'm wrong. I see SELECT IsDeleted FROM MyTable WHERE id = 1;
command generate 23
as the output.
Why does this happen? What's the meaning of maximum display width
?
My MySQL version is 5.7.20
.