Insert text to column using copy command

Поиск
Список
Период
Сортировка
От Shmagi Kavtaradze
Тема Insert text to column using copy command
Дата
Msg-id CAHY6maxTe5Gz9-X=BgTx7SewTUfiHHDM0Nx7EEuMxCXkFRPFzg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Insert text to column using copy command  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
I want to import text to a specific column and for other columns to specify literals/constants myself, using same copy command. For example, I have three columns: DocID(Int), SentenceID(serial), Sentence(varchar). I want with one COPY 

command to specify DocID value, SentenceID will be autoincremented and to populate Sentence column with data from text file. To show visually, 2339.txt file looks like this(Numbers at the beginning are sentence coordinates.):

0,189 A few years ago , when I was looking at middle schools for my daughter...
190,412 Having reported on a vogue for single-sex classrooms in the nineties...

After using COPY I want table entries to look like this:

DocID | SentenceID | Sentence

2339   |     1      |  A few years ago , when I was looking at middle ...
2339   |     2      |  Having reported on a vogue for single-sex classrooms in the nineties...

I was not able to find any way to use copy command to do so. Also is there possibility to omit sentence coordinates when importing data into table?

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

Предыдущее
От: Patrik Karlsson
Дата:
Сообщение: Re: What should I do after a power loss?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Insert text to column using copy command