pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Holger Jakobs <holger@jakobs.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Conditional query with copy command
Date: Thu, 26 Nov 2020 10:42:49 +0100
Message-ID: <f05f4e12-8eea-62fe-4a7b-3e5a0298aaf0@jakobs.com> (raw)
In-Reply-To: <CALg-PKDeVkeia_6Dv-_Tc0wm4qQVYPioe9i+D-FhERx84aKEzw@mail.gmail.com>
References: <CALg-PKDeVkeia_6Dv-_Tc0wm4qQVYPioe9i+D-FhERx84aKEzw@mail.gmail.com>

Hi,

Use the new syntax as of PostgreSQL 9.0:

copy hk_card_master_test from 
'C:/inetpub/wwwroot/cards/media/static/gc_card_master2L.csv' (format 
csv, header, encoding 'ISO_8859_5') where card_status = 'A'

This allows a simple WHERE condition as shown.


Am 26.11.20 um 09:27 schrieb Sachin Kumar:
> Hi Experts,
>
> I am uploading 10 million data using CSV, but I want to put a 
> condition on a column (Card_Status) inside the CSV that only where 
> Card_Status = A data should be uploaded rest data are not uploaded.
> Please guide me in modifying the query I am using to upload the data
> Query:-
> copy hk_card_master_test from 
> 'C:/inetpub/wwwroot/cards/media/static/gc_card_master2L.csv' with 
> delimiter ',' csv header encoding 'ISO_8859_5'
>
> -- 
>
> Best Regards,
> Sachin Kumar

-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012

Attachments:

  OpenPGP_signature (application/pgp-signature, 202B) download

view thread (4+ messages)  latest in thread

Message-ID: <f05f4e12-8eea-62fe-4a7b-3e5a0298aaf0@jakobs.com>
Permalink:  ../f05f4e12-8eea-62fe-4a7b-3e5a0298aaf0@jakobs.com/
Also on:    postgresql.org/message-id/f05f4e12-8eea-62fe-4a7b-3e5a0298aaf0@jakobs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: holger@jakobs.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Conditional query with copy command
  In-Reply-To: <f05f4e12-8eea-62fe-4a7b-3e5a0298aaf0@jakobs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox