Postgres中复制命令期间出错

时间:2017-05-18 09:03:44

标签: sql postgresql copy

我尝试使用COPY命令在Postgres中将数据插入到我的表中,并出现以下错误:

ERROR: extra data after last expected column

有我的COPY命令:

copy basic_data_cs from '/data/tmp/basic_data.csv' delimiter ';' header csv;

有我的表结构:

CREATE FOREIGN TABLE basic_data_cs ( oid4 BIGINT , oid3 BIGINT , date_creation date , date_modif date , id_princ text , nb_ref INTEGER , coobox INTEGER , otype_bin INTEGER , ra REAL , ra_prec SMALLINT , dec REAL , dec_prec SMALLINT , coo_err_maja FLOAT , coo_err_maja_prec SMALLINT , coo_err_mina FLOAT , coo_err_mina_prec SMALLINT , coo_err_angle SMALLINT , coo_qual TEXT , coo_wavelength TEXT , coo_bibcode TEXT , pmra REAL , pmra_prec SMALLINT , pmdec REAL , pmdec_prec SMALLINT , pm_err_maja FLOAT , pm_err_maja_prec SMALLINT , pm_err_mina FLOAT , pm_err_mina_prec SMALLINT , pm_err_angle SMALLINT , pm_qual text , pm_bibcode text , plx_value REAL , plx_prec SMALLINT , plx_error FLOAT , plx_error_prec SMALLINT , plx_qual TEXT , plx_bibcode TEXT , rvz_type TEXT , rvz_radvel REAL , rvz_radvel_prec SMALLINT , rvz_redshift REAL , rvz_redshift_prec SMALLINT , rvz_error FLOAT , rvz_error_prec SMALLINT , rvz_qual TEXT , rvz_nature TEXT , rvz_wavelength TEXT , rvz_bibcode TEXT , sp_type TEXT , sp_type_bin BIGINT , sp_qual text , sp_nature text , sp_bibcode text , morph_type text , morph_type_bin INTEGER , morph_qual text , morph_bibcode text , galdim_majaxis FLOAT , galdim_majaxis_prec SMALLINT , galdim_minaxis FLOAT , galdim_minaxis_prec SMALLINT , galdim_angle SMALLINT , galdim_incl SMALLINT , galdim_qual text , galdim_wavelength text , galdim_bibcode text , nb_parents INTEGER , nb_children INTEGER , nb_siblings INTEGER , id_princ_select text , hpx BIGINT , otype text , vlsr REAL , vlsr_prec SMALLINT , vlsr_error REAL , vlsr_error_prec SMALLINT , vlsr_wavelength text , vlsr_bibcode text) server cstore_server;

我的csv文件中有一行: 10396425;;2016-08-02;2016-08-02;SDSS J001954.03+025717.0;1;11278;-14680064;4.975139;7;2.954735;7;;-1;;-1;32767;C;O;2014A&A...563A..54P;;;;;;;;;;;;;;;;;;z;263064.159868091;0;2.9147;4;0.0003;4;C;s;O;2014A&A...563A..54P;;;;;;;;;;;;;;;;;;;;;;;(0.0868325562943782 , 0.0515698542739147);4635816;QSO;;;;;;;;;;

这个命令适用于另一个经典'具有相同CSV文件和相同命令的表。

2 个答案:

答案 0 :(得分:0)

这是因为,您的表包含78列,而您的csv分隔文件包含82个条目。enter image description here

enter image description here

答案 1 :(得分:0)

要么获得与表相同列的新csv,要么尝试 从那里check the top answer