Re: SQL copy from csv with explicit field ordering

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: SQL copy from csv with explicit field ordering
Дата
Msg-id Pine.LNX.4.30.0103021706380.775-100000@peter.localdomain
обсуждение исходный текст
Ответ на SQL copy from csv with explicit field ordering  (Terry Fielder <terry@greatgulfhomes.com>)
Список pgsql-sql
Terry Fielder writes:

> Is there somewhere that I can either enable the first line of CSV as
> header names
>
> OR
>
> Can I explicitly define my import field ordering from within the select
> statement?

No and no.  You will have to preprocess your file.  Something like this
will probably do:

#! /bin/sh
IFS=,
cat "inputfile" | \
while read COL1 COL2 COL3; do   echo "$COL3,$COL2,$COL1" >> "outputfile"
done

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



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

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: [HACKERS] why the DB file size does not reduce when 'delete' the data in DB?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Help creating rules/triggers/functions