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' ?
由于已经创建了序列,因此您可以使用
SELECT setval('biblios_id_seq', max(id)) FROM biblios;
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.