3

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

1
  • 3
    Try this ALTER SEQUENCE public.kvitansiya_id_seq as bigint MAXVALUE 9223372036854775807 Commented Nov 21, 2020 at 5:42

1 Answer 1

16

Thank you @akhilesh-mishra. The solution

ALTER SEQUENCE public.kvitansiya_id_seq as bigint MAXVALUE 9223372036854775807;

was wonderfull.

Sign up to request clarification or add additional context in comments.

3 Comments

FYI, the docs spell this out ALTER SEQUENCE under 'data_type'.
Dear Adrian @adrian-klaver, you are right 100 percently. I didn’t notice or understand this in the documentation.
Do you really need the max value in your command, I tried ALTER SEQUENCE seq_name as bigint and it set the max value automatically to what you mentioned

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.