Repository navigation
Description
-
tinyint, samllint, int and bigint don't support negative numbers now.
-
in both signed and unsigned tables, the ranges of them are not supported well as following.
mysql> create table numtable(a tinyint, b smallint, c int , d bigint);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(128,32767,2147483647,9223372036854775807);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(127,32768,2147483647,9223372036854775807);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into numtable values(127,32767,2147483648,9223372036854775807);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(127,32767,2147483647,9223372036854775808);
Query OK, 0 rows affected (0.00 sec)
mysql> select * from numtable;
+--------+-------------+----------------------+------+
| b | c | d | a |
+--------+-------------+----------------------+------+
| 32767 | 2147483647 | -9223372036854775808 | 127 |
| 32767 | -2147483648 | 9223372036854775807 | 127 |
| -32768 | 2147483647 | 9223372036854775807 | 127 |
| 32767 | 2147483647 | 9223372036854775807 | -128 |
+--------+-------------+----------------------+------+
4 rows in set (0.00 sec)
mysql> drop table numtable;
Query OK, 0 rows affected (0.00 sec)
mysql> create table numtable(a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(255,65535,4294967295,18446744073709551615);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(256,65535,4294967295,18446744073709551615);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(255,65536,4294967295,18446744073709551615);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into numtable values(255,65536,4294967296,18446744073709551615);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into numtable values(255,65536,4294967296,18446744073709551616);
ERROR 1105 (HY000): unkown error:[42P18]unsupport value: 1.84467e+19
mysql> select * from numtable;
+------------+------+------+-------+
| c | d | a | b |
+------------+------+------+-------+
| 0 | -1 | 255 | 0 |
| 4294967295 | -1 | 0 | 65535 |
| 4294967295 | -1 | 255 | 65535 |
| 4294967295 | -1 | 255 | 0 |
+------------+------+------+-------+
4 rows in set (0.01 sec)
Activity