Reputation: 10390
My SQL as follows:
create table test (
id tinyint unsigned,
id2 smallint unsigned
);
insert into test values ( 333, 66666);
select * from test
+------+-------+
| id | id2 |
+------+-------+
| 255 | 65535 |
+------+-------+
I am aware that the max for tinyint
is 255 and the max for smallint
is 65,535. What I am curious about is how the result above came about.
Upvotes: 0
Views: 886
Reputation: 14345
http://dev.mysql.com/doc/refman/5.7/en/insert.html
Setting a numeric column to a value that lies outside the column's range. The value is clipped to the closest endpoint of the range.
You should have seen a warning regarding this as well. Note that in STRICT
mode this will fail with an error unless you use INSERT IGNORE
.
Upvotes: 4