How to understand if a bigint is signed or unsigned in MySQL?


If you do not specify unsigned, then bigint will be signed. If you specify an unsigned, then bigint will be unsigned.

Let us first create a table −

mysql> create table DemoTable
   (
   Number bigint, // signed
   Number2 bigint unsigned // unsigned
   );
Query OK, 0 rows affected (1.08 sec)

Insert records in the table using insert command −

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)

Display all records from the table using select statement −

mysql> select * from DemoTable;

This will produce the following output −

+---------------------+----------------------+
| Number              | Number2              |
+---------------------+----------------------+
| 9223372036854775807 | 18446744073709551615 |
+---------------------+----------------------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements