setval('myfunsequence', 0)
От | Ian Harding |
---|---|
Тема | setval('myfunsequence', 0) |
Дата | |
Msg-id | sdf0544f.093@mail.tpchd.org обсуждение исходный текст |
Ответы |
Re: setval('myfunsequence', 0)
Re: setval('myfunsequence', 0) |
Список | pgsql-general |
The subject statement does not work for automagically generated sequences (minvalue is 1 by default, it seems.) I need toreset a sequence to where nextval('myfunsequence') is 1, and the only way to do it (I think) is to setval('myfunsequence',0). I can just create this particular sequence with minvalue 0 start 1, but I am wondering what is the downside to this beingthe default? Alternatively, is there a way to make setval accept a value that is $start - $increment as seems to happenon creation? Visual Aids Follow... test=# create sequence myfunsequence; CREATE test=# select nextval('myfunsequence'); nextval --------- 1 (1 row) test=# select nextval('myfunsequence'); nextval --------- 2 (1 row) test=# select setval('myfunsequence',0); ERROR: myfunsequence.setval: value 0 is out of bounds (1,9223372036854775807) test=# select setval('myfunsequence',1); setval -------- 1 (1 row) test=# select nextval('myfunsequence'); nextval --------- 2 (1 row) test=# drop sequence myfunsequence; DROP test=# create sequence myfunsequence minvalue 0 start 1; CREATE test=# select nextval('myfunsequence'); NOTICE: myfunsequence.nextval: sequence was re-created nextval --------- 1 (1 row) test=# select nextval('myfunsequence'); nextval --------- 2 (1 row) test=# select setval('myfunsequence',0); setval -------- 0 (1 row) test=# select nextval('myfunsequence'); nextval --------- 1 (1 row) Thanks!! Ian Harding Programmer/Analyst II Tacoma-Pierce County Health Department iharding@tpchd.org (253) 798-3549
В списке pgsql-general по дате отправления: