6 Ways to Fix “nextval: reached minimum value of sequence” in PostgreSQL

If you’re getting an error that reads something like “nextval: reached minimum value of sequence “sequence1” (-3)” in PostgreSQL, it’s probably because you’re trying to generate a new value from a descending sequence, but the sequence has already reached its minimum value.

We have a number options when it comes to dealing with this issue.

Continue reading

Fix “MINVALUE (…) must be less than MAXVALUE (…)” When Creating a Sequence in PostgreSQL

If you’re getting an error that reads something like “MINVALUE (1) must be less than MAXVALUE (1)” in PostgreSQL when you’re trying to create a sequence, it’s probably because your sequence’s minimum possible value is higher than the maximum value.

To fix this issue, be sure that the sequence’s maximum value is greater than the minimum value.

Continue reading

2 Ways to Apply a Sequence to a Table in SQL Server

In SQL Server, we can create sequence objects in order to generate a range of numbers that increment with each call to the sequence.

Although sequences are similar to identity columns, they are different in that they are generated independently of any table. It’s up to the application to generate the next sequence number before inserting it into the table. Therefore, we can apply a sequence to a table in the same way we would insert any other data into a table.

Here are two ways to apply sequence numbers into a table in SQL Server.

Continue reading

Fix “START value (…) cannot be greater than MAXVALUE (…)” When Creating a Sequence in PostgreSQL

If you’re getting an error that reads something like “START value (101) cannot be greater than MAXVALUE (100)” in PostgreSQL when you’re trying to create a sequence, it’s probably because your sequence’s maximum possible value is lower than the start value.

To fix this issue, change either the start value or maximum value so that the maximum value is greater than the start value.

Continue reading

6 Ways to Fix “nextval: reached maximum value of sequence” in PostgreSQL

If you’re getting an error that reads something like “nextval: reached maximum value of sequence “sequence1” (3)” in PostgreSQL, it’s probably because you’re trying to generate a new value from a sequence, but the sequence has already reached its maximum value.

We have quite a few options when it comes to dealing with this issue.

Continue reading