From: | "Papp Gyozo" <pgerzson(at)freestart(dot)hu> |
---|---|
To: | jrbeckstrom(at)voyager(dot)net, pgsql-php(at)postgresql(dot)org |
Subject: | Re: Use of Serial type |
Date: | 2002-09-18 22:48:24 |
Message-ID: | E17rnrW-0002o9-00@hapcibeno.freestart.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
2002. szeptember 18. 20:44 dátummal Jim Beckstrom ezt írta:
| Using php, I create a table with a SERIAL field. In the same
| script, the last thing I do is a COPY ... FROM ... USING
| DELIMITERS...to load data I have outputted from another system into a
| text delimited file. I didn't get the autoincrementing of the serial
| field to work, so I modified my output-from-another-system program to
| "manually" set the serial field value. That worked. However, it
| does not seem to have done a default SETVAL. Do I do a "manual"
| SETVAL of 1 greater than the highest value from the input text file,
| or am I missing something in the create and copy process?
|
| Jim Beckstrom
COPY is just a SQL-like shorthand for dumping and restoring database
tables, so it's not the convenient way to insert data as regular with
autoincrementing columns of type serial.
You should also consider about what would happen in concurrent usage if
you merely use "max+1". It may be better to use
setval('seq', currval('seq')+1);
But, AFAIR, Tom Lane wrote me that this solution can be also crashed in
concurrent usage. If you're interested in, please, search the
pgsql-general archives.
--
Papp, Győző
- pgerzson(at)freestart(dot)hu
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2002-09-18 23:08:14 | Re: Use of Serial type |
Previous Message | Keary Suska | 2002-09-18 19:35:32 | Re: Use of Serial type |