2

I am trying to store long integer in table. My table schema looks like below.

CREATE TABLE t7(a long integer);

and i am inserting below value.

insert into t7(a) values(16732595907054788167);

but when i do select i am getting numeric value as below

select * from t7;

1.67325959070548e+19

And I don't want to use string or blob as data type. How can I cast numeric to long integer while selecting.

CL.
  • 173,858
  • 17
  • 217
  • 259
kiranjc
  • 41
  • 2
  • 7
  • 16732595907054788167 exceeds the storage capacity of `long integer` (assuming its 64 bits) and approaches the limit for the unsigned equivalent. – Alex K. Oct 13 '16 at 15:33
  • So what do you think which data type to be used? – kiranjc Oct 13 '16 at 15:35
  • http://stackoverflow.com/questions/7142604/what-to-do-when-you-need-integers-larger-than-20-digits-on-mysql – Alex K. Oct 13 '16 at 15:37

1 Answers1

2

SQLite uses signed 64-bit integers, so the largest possible integer value is 9223372036854775807.

And it uses dynamic typing, so there's nothing you can do to get larger integers:

CREATE TABLE test(
    Col1 LONG INTEGER,
    Col2 UNSIGNED LONG INTEGER,
    Col3 EXTREMELY HUGE LONG LONG LONG INTEGER EXTENDED ENTERPRISE EDITION,
    Col4 EH WHATEVER
);
INSERT INTO test VALUES (9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
INSERT INTO test VALUES (9223372036854775808,9223372036854775808,9223372036854775808,9223372036854775808);

SELECT * FROM test; 
9223372036854775807  9223372036854775807  9223372036854775807  9223372036854775807
9.22337203685478e+18 9.22337203685478e+18 9.22337203685478e+18 9.22337203685478e+18

You have to use strings or blobs.

CL.
  • 173,858
  • 17
  • 217
  • 259