Use setval()
with a subquery to get the value from a table, eg
SELECT setval('seq_hours', (SELECT max(last_value)+1 FROM t));
EDIT : This solution only makes sense if you want to set the current value of a sequence based on a value from a given table. If you only want the next possible value of a sequence you should use nextval
as @a_horse_with_no_name suggested (see comments)
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.