Reputation: 6733
I want to import data from *.csv file to view in the PostgreSQL with 9.3 version. Here is the following script I have tried.
Example:
\copy "viewName" from 'D:\filename.csv' DELIMITER ';' CSV HEADER;
Error
ERROR: cannot copy to view "viewName"
Questions:
Where I am going wrong?
Or I need to copy it into table then select it from there?
Upvotes: 2
Views: 2632
Reputation: 3434
From http://www.postgresql.org/docs/9.3/static/sql-copy.html:
COPY can only be used with plain tables, not with views. However, you can write COPY (SELECT * FROM viewname) TO ....
Since COPY
is the basis for \copy
, you might want to try your code with a table instead of a view and the select from there.
Upvotes: 2