Changing minvalue of Postgres's sequence
How about setting them all at once:
ALTER SEQUENCE product_id_seqMINVALUE 10000START 10000RESTART 10000;
That should change the minimum, starting, and current values all to 10000 and thus make everything consistent.
PostgreSQL has several functions that operate on sequences. In addition to the other guidance here, you could use
SELECT setval('product_id_seq ', 10000); -- Next nextval() returns 10001
I Have done the following test, My version is 9.0.
--create sequenceskytf=> CREATE SEQUENCE seq_testskytf-> START WITH 1skytf-> INCREMENT BY 1skytf-> NO MINVALUEskytf-> NO MAXVALUEskytf-> CACHE 1;CREATE SEQUENCEskytf=> \d seq_test Sequence "skytf.seq_test" Column | Type | Value ---------------+---------+--------------------- sequence_name | name | seq_test last_value | bigint | 1 start_value | bigint | 1 increment_by | bigint | 1 max_value | bigint | 9223372036854775807 min_value | bigint | 1 cache_value | bigint | 1 log_cnt | bigint | 1 is_cycled | boolean | f is_called | boolean | fskytf=> select nextval('seq_test'); nextval --------- 1(1 row)--alter sequence skytf=> alter sequence seq_test restart with 100;ALTER SEQUENCEskytf=> \d seq_test Sequence "skytf.seq_test" Column | Type | Value ---------------+---------+--------------------- sequence_name | name | seq_test last_value | bigint | 100 start_value | bigint | 1 increment_by | bigint | 1 max_value | bigint | 9223372036854775807 min_value | bigint | 1 cache_value | bigint | 1 log_cnt | bigint | 1 is_cycled | boolean | f is_called | boolean | fskytf=> select nextval('seq_test'); nextval --------- 100(1 row)