Re: Using \copy to populate a table
Adrian Klaver <adrian.klaver@aklaver.com>
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: rob stone <floriparob@tpg.com.au>,
PostGreSQL MailingList <pgsql-general@postgresql.org>
Date: 2026-03-15T15:30:44Z
Lists: pgsql-general
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 adrian.klaver@aklaver.com