0

The 'id' from my table 'biblios' didn't autoincrement. It had already data in it and the 'id' go from 112 to 175.

I altered the table to add nextval, doing this:

CREATE SEQUENCE biblios_id_seq
OWNED by biblios.id;
ALTER TABLE biblios
ALTER id
SET DEFAULT nextval('biblios_id_seq'::regclass);

This starts the id at '1'.

How do I make the autoincrement continue at '176' ?

2 Answers 2

1

Since the sequence is already created, you can reset it using

SELECT setval('biblios_id_seq', max(id)) FROM biblios;
Sign up to request clarification or add additional context in comments.

Comments

0

Use MINVALUE minvalue:

CREATE SEQUENCE biblios_id_seq
MINVALUE 176
OWNED by biblios.id;
ALTER TABLE biblios
ALTER id
SET DEFAULT nextval('biblios_id_seq'::regclass);

Comments

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.