문제

simple question I think but I can't seem to find the answer through Googling etc.

I am importing csv data into a postgresql table via psql. I can do this fine through the pgAdmin III GUI but am now using Codio Online IDE where it is all done through psql.

How can I import into the Postgresql table and skip the first 'id' auto incrementing column?

In pgAdmin it was as simple as unselecting the id column on the 'columns to import' tab.

So far I have in the SQL Query toolbox

COPY products FROM '/media/username/rails_projects/app/db/import/bdname_products.csv' DELIMITER ',' CSV; 

Alternatively, is it possible to get an output on the SQL that PgAdmin III used after you execute an Import using the menu Import command?

Thank you for your consideration.

도움이 되었습니까?

해결책

As explained in the manual, copy allows you to specify a field list to read, like this:

COPY table_name ( column_name , ... )  FROM 'filename'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top