Re: query option in COPY postgres - Mailing list pgsql-sql

From David G. Johnston
Subject Re: query option in COPY postgres
Date
Msg-id CAKFQuwYNmOMSCfy_nuTwhh3LReBuyJUyykLkHT7eyAYSmALwSQ@mail.gmail.com
Whole thread Raw
In response to query option in COPY postgres  (masyaf <kavtaradze.s@gmail.com>)
List pgsql-sql
On Fri, Nov 6, 2015 at 1:22 PM, masyaf <kavtaradze.s@gmail.com> wrote:
According to COPY documentation , I can use query option when exporting data.
Can I use query VALUES when loading data into tables from txt file? If I
have 2 columns and I want to insert record manually in the first
column(SentenceID) and insert data in the second column(Sentence) from text
file. Is it something like:

copy foo1(Sentence) | (VALUES (2339)) from '/path/to/sentence.txt' with
delimiter '*';

Directly? No.  the entirity of the data being imported must exist within the specified input file.  If the file contains fewer columns than the target table, or in a differing order, you can specify column names.  Any columns not specified will take on their default value.  If the column is a "serial" column is will get its default value from the corresponding sequence.​


How to use exactly options in COPY command, it has {} | [] symbols in
documentation.

​{} - means required; choose one of the listed options
[] - mean options; choose on of the listed options (possibly only one)​

​David J.​

pgsql-sql by date:

Previous
From: masyaf
Date:
Subject: query option in COPY postgres
Next
From: Adrian Klaver
Date:
Subject: Re: query option in COPY postgres