Hayrulla Melibayev
Hayrulla Melibayev

Reputation: 532

Changing a sequence datatype from INT to BIGINT PostgreSQL

Hi I have PostgreSQL database with some values. When I created the tables, I didn’t pay much attention to their ID column. Now if I check the sequences, I see that the max value of some of them is of type int. How to change them to bigint without changing the IDs of the data. I changed the ID fields type in the tables from int to bigint. then ALTER SEQUENCE public.kvitansiya_id_seq MAXVALUE 9223372036854775807; command returns an error such as

SQL Error [22023]: ERROR: MAXVALUE (9223372036854775807) out of sequence data type (integer).

Here is photo of sequences tables on DBeaver.

enter image description here

Upvotes: 3

Views: 7114

Answers (1)

Hayrulla Melibayev
Hayrulla Melibayev

Reputation: 532

Thank you @akhilesh-mishra. The solution

ALTER SEQUENCE public.kvitansiya_id_seq as bigint MAXVALUE 9223372036854775807;

was wonderfull.

Upvotes: 14

Related Questions