Re: reinitialize a sequence?
От | Ross J. Reedstrom |
---|---|
Тема | Re: reinitialize a sequence? |
Дата | |
Msg-id | 20001205112737.B13143@rice.edu обсуждение исходный текст |
Ответ на | Re: reinitialize a sequence? ("Ross J. Reedstrom" <reedstrm@rice.edu>) |
Список | pgsql-sql |
Following up to myself: There is in fact a bug in 7.0.2 that's been fixed in 7.0.3 which causes my select below not to work. The name of the sequence is now stored with double quotes around it, to handle the mixed case names problem, so the query needs to look like (untested: note added double quote to last where clause): select 'SELECT setval(\'"' || substr(adsrc,10,(length(adsrc) - 17)) || '"\', max("' || attname || '")) FROM "'|| relname || '";' from pg_class c, pg_attribute a, pg_attrdef d where c.oid=d.adrelid and a.attrelid=c.oid and d.adnum=a.attnum and d.adsrc ~ ('nextval\\(\'"'||relname); On Tue, Dec 05, 2000 at 10:10:12AM -0600, Ross J. Reedstrom wrote: > On Mon, Dec 04, 2000 at 03:51:35PM -0800, Dan Lyke wrote: > > Bruno Boettcher writes: > > > is there a simple way to tell all sequences to take the max value +1 of > > > their respective tables? (a bit like the vacuum command?) > > > > This is completely gross, but what I've done: > > > > Hmm, what I usually do is something like: > > SELECT setval('tablename_serfield_seq',max(serfield)) FROM tablename; > > Ross -- Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> NSBRI Research Scientist/Programmer Computer and Information Technology Institute Rice University, 6100 S. Main St., Houston, TX 77005
В списке pgsql-sql по дате отправления: