Question

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.

Was it helpful?

Solution

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

COPY table_name ( column_name , ... )  FROM 'filename'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top