Re: serial, sequence, and COPY FROM

Поиск
Список
Период
Сортировка
От Brandon Aiken
Тема Re: serial, sequence, and COPY FROM
Дата
Msg-id F8E84F0F56445B4CB39E019EF67DACBA2F1E55@exchsrvr.winemantech.com
обсуждение исходный текст
Ответ на serial, sequence, and COPY FROM  (rloefgren@forethought.net)
Ответы Re: serial, sequence, and COPY FROM  (Scott Marlowe <smarlowe@g2switchworks.com>)
Re: serial, sequence, and COPY FROM  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
Serial fields have a default value of nextval, so if you add an 18th
field to your text file with DEFAULT in every record it should work as
intended.

--
Brandon Aiken
CS/IT Systems Engineer

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of
rloefgren@forethought.net
Sent: Tuesday, September 12, 2006 12:28 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] serial, sequence, and COPY FROM

All,

I have a pipe delimited text file I'm trying to copy to a table. The
file has 17 fields per line. The table has 18, with that last field
(record) a serial with sequence. I have done:
select setval('sequence_name_seq', 555, 'TRUE')
but when I do: COPY tablename FROM '/path/to/file/file.txt' delimiter
'|'
the copy stops at the first row, insisting that it's missing data for
the field record. Well, yeah...
I can make this work with inserts but not with COPY FROM. What I've
been doing is dumping it into a mysql table with an auto_increment
field and then dumping that into a text file and using that for the
COPY FROM; certainly clumsy. How might this be done?

r


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

В списке pgsql-general по дате отправления:

Предыдущее
От: John McCawley
Дата:
Сообщение: Re: Bytea to Text problems
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: serial, sequence, and COPY FROM