public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: rob stone <[email protected]>
To: PostGreSQL MailingList <[email protected]>
Subject: Re: Using \copy to populate a table
Date: Sun, 15 Mar 2026 08:30:44 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On 3/15/26 12:11 AM, rob stone wrote:
> psql (18.3 (Debian 18.3-1+b1))
> Type "help" for help.
> 
> Debian OS is forky.
> 
> When setting up a new development database, the following occurred:-
> 

> How do we fix this? Alter all the nulls to zeroes in the file or write
> a program to dissect the file and create individual insert statements?

CSV is a text format and in:

C|0|pageloader|||null|null|null|null|t|f|f|0

the null values are the string 'null' which indeed is not a valid syntax 
for a smallint.

> 
> Has anybody else had this problem and if so what was the solution?

Do you have control over whatever creates the file?

An option is to create a staging table that is has all string fields, 
import into it and then do clean up before moving to final table.


> 
> Thanks,
> Rob
> 
> 


-- 
Adrian Klaver
[email protected]






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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Using \copy to populate a table
  In-Reply-To: <[email protected]>

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

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