First of all the table to be loaded
CREATE TABLE targetas you can see one of the column names is a reserved word! Bad practice, but it's here to add some spice.
code character(3) NOT NULL,
"name" character varying(50) NOT NULL,
CONSTRAINT pk_1 PRIMARY KEY (code)
Now the data
code;name;amountas you can see it's delimited by ";", has an header row and contains NULLs, which we want to preserve in our target table.
This file is named 2beloaded.csv and it's placed in c:\
After logging in to PostgreSQL and creating the table with the statement provided above it's time to load it
--target table with columns listed
target(code, "name", amount)
--list of options
--switches on csv mode
--ignores first line as an header line
--sets the delimiter
null as 'NULL'
--preserves nulls by telling the database what represents a NULL
Quite nice, isn't it?
Hope this helps.