如何在 MySQL 中理解 bigint 是带符号还是无符号?
如果您未指定无符号,则 bigint 将为带符号。如果您指定无符号,则 bigint 将为无符号。
我们先创建一个表 -
mysql> create table DemoTable ( Number bigint, // signed Number2 bigint unsigned // unsigned ); Query OK, 0 rows affected (1.08 sec)
通过 insert 命令在表中插入记录 -
mysql> insert into DemoTable values(18446744073709551615,18446744073709551615); ERROR 1264 (22003): Out of range value for column 'Number' at row 1 mysql> insert into DemoTable values(9223372036854775807,18446744073709551615); Query OK, 1 row affected (0.28 sec)
通过 select 语句从表中显示所有记录 -
mysql> select * from DemoTable;
这将产生以下输出 -
+---------------------+----------------------+ | Number | Number2 | +---------------------+----------------------+ | 9223372036854775807 | 18446744073709551615 | +---------------------+----------------------+ 1 row in set (0.00 sec)
广告