postgresql中copy命令的语法错误

时间:2014-04-08 15:22:00

标签: postgresql bulkinsert

我使用了命令:

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 ';'

我收到以下错误:

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

我想知道我的代码中的错误

1 个答案:

答案 0 :(得分:1)

Linux上的有效COPY syntax for version 9.1应为:

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,而不是 USING DELIMITER代替 DELIMITERS

不要使用primary作为列名。 It's a reserved word.