Re: unused columns in copy

Поиск
Список
Период
Сортировка
От nha
Тема Re: unused columns in copy
Дата
Msg-id 4A6509B7.7010400@free.fr
обсуждение исходный текст
Ответ на Re: unused columns in copy  (Marcin Stępnicki <mstepnicki@gmail.com>)
Список pgsql-sql
Hello,

Le 21/07/09 0:59, Marcin Stępnicki a écrit :
> On Mon, Jul 20, 2009 at 3:22 PM, chester c young<chestercyoung@yahoo.com> wrote:
>> is there a way for COPY FROM to ignore unused columns in CSV?
>>
>> in other words, if table t1 has columns c1, c2, and if csv has columns c1, c3, c2, could I do something like
>>
>> COPY t1( c1, null, c2 ) FROM 'file.csv'
> 
> No, but you can use pgloader which can easily deal with your problem
> and much more. http://pgfoundry.org/projects/pgloader/
> 

Depending on PostgreSQL version, copy restrictions may be performed (see
also documentation of PostgreSQL 8.4):
http://www.postgresql.org/docs/8.4/interactive/sql-copy.html

Assuming that a CSV file contains data with column headers c1, c2, and
c3, the following statement would retrieve only columns c1 and c2 from
this file to a table t1:
COPY t1(c1, c2) FROM '/path/to/file.csv';

Regards.
--
nha / Lyon / France.


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

Предыдущее
От: nha
Дата:
Сообщение: Re: how to tell if column set on update
Следующее
От: JJ
Дата:
Сообщение: Storing/sorting hex data in PostgreSQL