-1

I'm hoping that there is a simple fix for this. I have a database column in which I store a number. I knew that the numbers would get pretty big, so I set the field to 'bigint'. However it will not store a number larger than 9223372036854775808.

Why is this?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
user3320550
  • 123
  • 1
  • 2
  • 9

3 Answers3

5

Quoting from the manual:

BIGINT[(M)] [UNSIGNED] [ZEROFILL]
A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

TimWolla
  • 31,849
  • 8
  • 63
  • 96
3

You've hit the bigint maximum size. This is a limitation due to the way the number is stored on the computer. It's the maximum size number you can represent with 8 bytes.

If you need to store a bigger number, consider using another method. You could use varchars but you will need to convert if you're doing math operations on it.

akirilov
  • 322
  • 1
  • 6
1

I think you're using a signed BIGINIT:

Range of a signed bigint: -9223372036854775808 - 9223372036854775807 Range of an unsigned bigint: 0- 18446744073709551615

Use ALTER TABLE to modify the column:

ALTER TABLE t1 MODIFY col1 BIGINT UNSIGNED;
ediardo
  • 147
  • 5