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

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" (

Show Detail

postgresql sequence getting max_value

How to get max_value and min_value Postgres sequence? I created the sequence using this statement create sequence seqtest increment 1 minvalue 0 maxvalue 20; I tried this query select max_value ...

Show Detail

Oracle - Set the sequence value to max indentity value of the table within trigger

I need to get the max indentity value from the table and set the sequence to that value. For that I'm trying to read max indentity value from the table(on which current trigger is fired) within ...

Show Detail

Use max value of a column to restart postgresql sequence

I need to restart the table sequence after manually importing data and want to dynamically use the maximum value (+1) currently present in the id column. I identify the value with SELECT coalesce...

Show Detail

Set max column value as sequence start value with liquibase tags

I wonder if it possible to get maximum column value from a certain table and set it as start sequence value with no pure sql. The following code doesn't work: <property name="maxId" value="(...

Show Detail

Create Sequence in PostgreSQL

I am trying to create a new sequence in PostgreSQL with the start value being the max of all available ids in all the tables using the following query: CREATE SEQUENCE idschema.global_id_sequence

Show Detail

how to change default min sequence value for database

I have this doubt, how to configure the default min value for sequence in postgresql? Is it possible? I want to change the default min value of sequence in Postgresql for all my table in a databas...

Show Detail

Snowflake sequence max value and Cycle

I am trying to create a sequence in snowflake with max value and cycle. However I am not able to find any document where it says how to provide the max value. But again I see in doc it says Snowflake

Show Detail

How to refer to a value in a PostgreSQL script?

I'd like to use the max value to feed the creation of a sequence. For instance, I am getting the max id value and I'd like to use this value: DO $$ DECLARE min_value Integer; BEGIN SELEC...

Show Detail

How to retrieve Postgresql Sequence-cache value from Postgresql Catalog tables?

I have used this below query to get the complete information of Sequence objects from the Postgresql catalog table select s.sequence_name, s.start_value, s.minimum_value, s.maximum_value, s.increm...

Show Detail