尝试从CSV文件复制数据并将其保存在带有postgresql的表中。
的脚本在带有Postgresql版本11.6的psql中运行脚本
用于运行的命令:
\i script.sql
脚本:
create table data
(
col_1 varchar(64)
, col_2 varchar(64)
, col_3 varchar(64)
, col_4 varchar(64)
, col_5 varchar(64)
, col_6 varchar(64)
, col_7 varchar(128)
, col_8 varchar(64)
, col_9 varchar(64)
, col_10 varchar(64)
, col_11 bigint
)
copy data from 'data.csv' with (format csv);
错误消息:
ERROR: syntax error at or near "copy"
LINE 15: copy data from 'data.csv' with (format csv...
^
还尝试了基于this tutorial
的另一种方法create table data
(
col_1 varchar(64)
, col_2 varchar(64)
, col_3 varchar(64)
, col_4 varchar(64)
, col_5 varchar(64)
, col_6 varchar(64)
, col_7 varchar(128)
, col_8 varchar(64)
, col_9 varchar(64)
, col_10 varchar(64)
, col_11 bigint
)
copy data(col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, col_9, col_10, col_11)
from 'data.csv' delimiter ',' csv header;
错误消息:
ERROR: syntax error at or near "copy"
LINE 15: copy data(col_1, col_2, col_3, col_4...