COPY from CSV, passing in default value? - Mailing list pgsql-general

From adebarros
Subject COPY from CSV, passing in default value?
Date
Msg-id 1337016663146-5708672.post@n5.nabble.com
Whole thread Raw
Responses Re: COPY from CSV, passing in default value?
Re: COPY from CSV, passing in default value?
List pgsql-general
Assuming I have a table structured like so:

CREATE TABLE salaries (
    Town varchar(30),
    County varchar(30),
    Supervisor varchar(30),
    StartDate date,
    Salary int,
    Benefits int
);

If I have a CSV with only three of those fields, I can import like this:

COPY salaries (Town, Supervisor, Salary)
FROM 'C:\salaries.csv'
WITH (FORMAT CSV);

However, what if I wanted to assign a default value during import to
populate the County field? In my dreams it would be something like this
(which does not work):

COPY salaries (Town, 'County Name', Supervisor, Salary)
FROM 'C:\salaries.csv'
WITH (FORMAT CSV);

Any ideas?

Thanks.


--
View this message in context:
http://postgresql.1045698.n5.nabble.com/COPY-from-CSV-passing-in-default-value-tp5708672.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

pgsql-general by date:

Previous
From: Paulo Correia
Date:
Subject: Re: Postgres 9.0 Streaming Replication and Load Balancing?
Next
From: Kyle Lanclos
Date:
Subject: Performance of PostgreSQL B+-tree algorithm