How to store unsigned long in postgresql?

Member

by darion , in category: MySQL , 5 months ago

How to store unsigned long in postgresql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by tressie.damore , 5 months ago

@darion 

In PostgreSQL, you can store an unsigned long integer by using the bigint data type. The bigint data type can store signed 64-bit integers, which can accommodate unsigned long values as well. To store an unsigned long value, you can use the following syntax:

1
2
3
CREATE TABLE example_table (
   id bigint
);


You can then insert an unsigned long value into the table as follows:

1
INSERT INTO example_table (id) VALUES (18446744073709551615);


When querying the table, you can use the bigint data type to retrieve the values:

1
SELECT * FROM example_table;


This will return the unsigned long integer that was stored in the table.