Re: COPY FROM WHEN condition - Mailing list pgsql-hackers

From Christoph Moench-Tegeder
Subject Re: COPY FROM WHEN condition
Date
Msg-id 20181011085925.5zopu7jvxzs5c4xq@squirrel.exwg.net
Whole thread Raw
In response to COPY FROM WHEN condition  (Surafel Temesgen <surafel3000@gmail.com>)
Responses Re: COPY FROM WHEN condition  (Surafel Temesgen <surafel3000@gmail.com>)
List pgsql-hackers
## Surafel Temesgen (surafel3000@gmail.com):

> Currently we can not moves data from a file to a table based on some
> condition on a certain column

You can:
  COPY ( query ) TO 'filename';

There's even an example in the documentation:
https://www.postgresql.org/docs/10/static/sql-copy.html
"To copy into a file just the countries whose names start with 'A':
 COPY (SELECT * FROM country WHERE country_name LIKE 'A%') TO '/usr1/proj/bray/sql/a_list_countries.copy';"

Regards,
Christoph

-- 
Spare Space.


pgsql-hackers by date:

Previous
From: Surafel Temesgen
Date:
Subject: COPY FROM WHEN condition
Next
From: Surafel Temesgen
Date:
Subject: Re: COPY FROM WHEN condition