Re: COPY TO order

Поиск
Список
Период
Сортировка
От Guy Fraser
Тема Re: COPY TO order
Дата
Msg-id 407C3813.8050400@incentre.net
обсуждение исходный текст
Ответ на Re: COPY TO order  (Clodoaldo Pinto Neto <clodoaldo_pinto@yahoo.com.br>)
Ответы Re: COPY TO order  (Clodoaldo Pinto Neto <clodoaldo_pinto@yahoo.com.br>)
Список pgsql-general
Ahh, I see.

Like this from the command line :

psql --no-align --tuples-only --field-separator , -c "select
data,comment from test_table order by test_id ;" database >/tmp/file

 From psql prompt :

\a\t\f,
select data,comment from test_table order by test_id \g /tmp/file
\a\t\f|

Either way you should get a file {/tmp/file} contaning :

27,some kind of entry
32,another kind of entry
16,yet another entry
...



Clodoaldo Pinto Neto wrote:

> --- Guy Fraser <guy@incentre.net>
>
>
>>If you have a 'serial' or 'bigserial' field like this :
>>
>>create table test_table (
>>test_id bigserial,
>>data integer,
>>comment text
>>);
>>
>>and you use :
>>
>>copy test_table (data,comment)
>>from '/wherever/the/file/is'
>>using delimiters ',';
>>
>>
>>to insert data like this :
>>
>>27,some kind of entry
>>32,another kind of entry
>>16,yet another entry
>>...
>>
>>Assuming this is the first set of data entered the table will get populated
>>with :
>>
>> 1 | 27 | some kind of entry
>> 2 | 32 | another kind of entry
>> 3 | 16 | yet another entry
>>...
>>
>>I have used this in the past and it works well.
>>
>>
>
>The problem I have is with COPY TO and not COPY FROM as I need to write a file.
>
>
...snip...



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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Join works in 7.3.6, fails in 7.4.2
Следующее
От: Chris Kratz
Дата:
Сообщение: insert rule not firing on insert with exists subselect