PostgreSQL: Set MAX Value for Sequence to a Higher Value
NickName:Prof. Falken Ask DateTime:2019-06-11T04:52:43

PostgreSQL: Set MAX Value for Sequence to a Higher Value

Currently I am importing data from a RabbitMQ worker to a table in postgreSQL. In doing so I received this error:

4|tiq-work | error: nextval: reached maximum value of sequence "table_id_seq" (2147483647)

table.id has a data type of int8 (bigint) which has a range of 9223372036854775807

I tried to set the max value using this command from the postgreSQL documentation:

alter sequence schema.table_id_seq maxvalue 9223372036854775807;

But then receive this error:

SQL Error [22023]: ERROR: MAXVALUE (9223372036854775807) is out of range for sequence data type

This appears to be because the range for sequence data type is the same as the integer data type (2147483647).

Is there a way to force this to go higher? I still have a lot of data to load.

Copyright Notice:Content Author:「Prof. Falken」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56533378/postgresql-set-max-value-for-sequence-to-a-higher-value

More about “PostgreSQL: Set MAX Value for Sequence to a Higher Value” related questions