0

I used the command:

COPY studentapp_deg_course_cat(degree_code, specialization, category_level1, category_level2, category_level3, min_credit, max_credit, primary)
FROM '/home/abhishek/Downloads/courses.csv'
USING DELIMITERS ';'

and i am getting the following error:

ERROR:  syntax error at or near "COPY" LINE 1: COPY studentapp_deg_course_cat(degree_code, specialization,...
        ^

********** Error **********

ERROR: syntax error at or near "COPY" SQL state: 42601 Character: 1

I would like to know the error in my code

2
  • Your version of Postgres? Your OS? Commented Apr 8, 2014 at 15:27
  • i am using ubuntu 13.04 and postgres version is 9.1.11 Commented Apr 8, 2014 at 15:29

1 Answer 1

1

Valid COPY syntax for version 9.1 on Linux should be:

COPY studentapp_deg_course_cat(degree_code, specialization, category_level1,
            category_level2, category_level3, min_credit, max_credit, "primary")
FROM '/home/abhishek/Downloads/courses.csv'
WITH (DELIMITER ';')

WITH, not USING.
DELIMITER instead of DELIMITERS.

And do not use primary as column name. It's a reserved word.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi i tried the command you gave and i am still getting the same error..There are a few blank spaces in the cells of the csv file. Might that be a reason?
@AbhishekReddy: No, you get a syntax error. You never even get that far ... Found & fixed another one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.