| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Kevin Brannen <kevinb(at)nurseamerica(dot)net> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: serial columns & loads misfeature? |
| Date: | 2002-06-28 19:03:39 |
| Message-ID: | 5982.1025291019@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Kevin Brannen <kevinb(at)nurseamerica(dot)net> writes:
> I was expecting the system to realize new "keys" had been inserted, and
> so when the "nextval" that implicitly happens on a serial field is run,
> it would "know" that it was too small and return "max(s)+1".
It does not, and I'm not convinced that it should. Manual insertion
of values into an autonumbering column seems like, well, a manual
operation. If you're going to bypass the autonumbering then you should
also be responsible for setting the sequence counter to whatever you
want it to be afterwards.
> I realize I can fix this by writting a Perl/DBI script to read the list
> of sequences, and do [conceptually]:
The usual locution is just
select setval('seqname', (select max(col) + 1 from table));
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2002-06-28 19:11:35 | Re: serial columns & loads misfeature? |
| Previous Message | Manfred Koizar | 2002-06-28 19:01:58 | Re: serial columns & loads misfeature? |