Search Postgresql Archives

COPY from CSV, passing in default value?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux