From: | Shmagi Kavtaradze <kavtaradze(dot)s(at)gmail(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Insert text to column using copy command |
Date: | 2015-11-08 16:18:09 |
Message-ID: | CAHY6maxTe5Gz9-X=BgTx7SewTUfiHHDM0Nx7EEuMxCXkFRPFzg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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?
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-11-08 16:35:37 | Re: Insert text to column using copy command |
Previous Message | Patrik Karlsson | 2015-11-07 08:15:51 | Re: What should I do after a power loss? |