postgres抛出的copy from语法错误

sshcrbum  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(453)

我正在尝试将数据从管道分隔的文本文件导入我的postgres data_master table。我的命令如下:

COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' 
    WITH FORMAT csv, 
    DELIMITER '|', 
    HEADER TRUE;

错误如下:

temp=# COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' WITH FORMAT csv, DELIMITER '|', HEADER TRUE;
ERROR:  syntax error at or near "FORMAT"
LINE 1: .../me/Documents/DATA/39079.txt' WITH FORMAT csv...
                                              ^
temp=# show server_version;
-[ RECORD 1 ]--+-----
server_version | 10.1

从文档来看,这似乎是命令的有效语法。我做错了什么?
编辑:我在删除逗号后也尝试了这个方法,得到了相同的结果:

temp=# COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' WITH FORMAT CSV DELIMITER '|' HEADER TRUE;
ERROR:  syntax error at or near "FORMAT"
LINE 1: .../me/Documents/DATA/39079.txt' WITH FORMAT CSV...
                                              ^
yrdbyhpb

yrdbyhpb1#

语法如下 WITH 应该在括号中。

COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' 
  WITH (
    FORMAT csv, 
    DELIMITER '|', 
    HEADER TRUE
  );

相关问题