pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to manage null value while copy data from csv
3+ messages / 3 participants
[nested] [flat]
* How to manage null value while copy data from csv
@ 2020-12-31 06:25 Sachin Kumar <sachinkumaras@gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Sachin Kumar @ 2020-12-31 06:25 UTC (permalink / raw)
To: pgsql-admin@lists.postgresql.org; pgsql-admin; krishna@thewebconz.com
Hi experts,
when I am uploading data (CSV File) using the COPY command. I am getting
below mention error.
ERROR: null value in column "adj_type" violates not-null constraint.
When I define null it gives no error message, but how to manage null value
n data without defining it, because there is many more columns. when it
defines null it gives an error if null value comes you are violating null.
Please suggest how to manage null value in postgresql?
--
Best Regards,
Sachin Kumar
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to manage null value while copy data from csv
@ 2020-12-31 07:59 Gavan Schneider <list.pg.gavan@pendari.org>
parent: Sachin Kumar <sachinkumaras@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Gavan Schneider @ 2020-12-31 07:59 UTC (permalink / raw)
To: Sachin Kumar <sachinkumaras@gmail.com>; +Cc: pgsql-admin@lists.postgresql.org; pgsql-admin; krishna@thewebconz.com
On 31 Dec 2020, at 17:25, Sachin Kumar wrote:
> when I am uploading data (CSV File) using the COPY command. I am
> getting
> below mention error.
>
> ERROR: null value in column "adj_type" violates not-null constraint.
>
This indicates the relevant column in the database table has been
defined to **never** allow a NULL value.
> When I define null it gives no error message, but how to manage null
> value
> n data without defining it, because there is many more columns. when
> it
> defines null it gives an error if null value comes you are violating
> null.
>
What is meant by “define null”? Is this where you put a real value
in the CSV, or a dummy text value such as “null”?
You could massage the csv so all the gaps get a dummy value, then handle
this in the SQL table.
Otherwise
> Please suggest how to manage null value in postgresql?
>
Basic options
1. Fix the raw csv data so there are no gaps — the person who defined
the database wasn’t expecting any
2. Fix the database so it will accept NULL values — assuming this is
ok with the business model
3. Accept the csv data into a temporary table which tolerates NULL,
massage the data then insert into the real database
Regards
Gavan Schneider
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to manage null value while copy data from csv
@ 2021-01-18 15:40 Blairemaloneback <blairemaloneback@gmail.com>
parent: Sachin Kumar <sachinkumaras@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Blairemaloneback @ 2021-01-18 15:40 UTC (permalink / raw)
To: Sachin Kumar <sachinkumaras@gmail.com>; +Cc: Pgsql-Admin <pgsql-admin@lists.postgresql.org>; pgsql-admin; Krishna <krishna@thewebconz.com>
Got it, thanks.
>
> On Dec 31, 2020 at 1:26 AM, <Sachin Kumar (mailto:sachinkumaras@gmail.com)> wrote:
>
>
>
> Hi experts,
>
>
> when I am uploading data (CSV File) using the COPY command. I am getting below mention error.
>
>
>
> ERROR: null value in column "adj_type" violates not-null constraint.
>
>
>
> When I define null it gives no error message, but how to manage null value n data without defining it, because there is many more columns. when it defines null it gives an error if null value comes you are violating null.
>
>
>
> Please suggest how to manage null value in postgresql?
>
>
>
>
>
>
> --
>
>
> Best Regards,
> Sachin Kumar
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-01-18 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 06:25 How to manage null value while copy data from csv Sachin Kumar <sachinkumaras@gmail.com>
2020-12-31 07:59 ` Gavan Schneider <list.pg.gavan@pendari.org>
2021-01-18 15:40 ` Blairemaloneback <blairemaloneback@gmail.com>
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