Re: COPY FROM WHEN condition

Christoph Moench-Tegeder <cmt@burggraben.net>

From: Christoph Moench-Tegeder <cmt@burggraben.net>
To: pgsql-hackers@lists.postgresql.org
Date: 2018-10-11T08:59:25Z
Lists: 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.


Commits

  1. Remove unused struct member, enforce multi_insert callback presence.

  2. Separate per-batch and per-tuple memory contexts in COPY

  3. Fix handling of volatile expressions in COPY FROM ... WHERE

  4. Allow COPY FROM to filter data using WHERE conditions

  5. Remove obsolete netbsd dynloader code