| От | Tom Lane |
|---|---|
| Тема | Re: Insert from CSV (comma separated values) file |
| Дата | |
| Msg-id | 11835.1042694047@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Insert from CSV (comma separated values) file ("Brian Johnson" <bjohnson@jecinc.on.ca>) |
| Список | pgsql-novice |
"Brian Johnson" <bjohnson@jecinc.on.ca> writes:
> I need to insert some values from a CSV file. It's a little more
> complicated than that since I have to do a SELECT query (from one
> table) on one of the values to get the proper value for the INSERT
> query (into another table)
Doesn't seem that hard. Insert the raw data into a temp table using
a command along the lines of
COPY TO temp_table ... WITH DELIMITER ','
and then construct the final result rows with something like
INSERT INTO dest_table
SELECT ..., (SELECT ... FROM other_table), ... FROM temp_table
If that's not enough to get you going, let's see more details.
regards, tom lane
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера