1

我的命令是

\copy meta.amz_payment1("Date", settlement_id, type, order_id, sku, 

description, quantity, marketplace, fulfillment, order_city, order_state, 

order_postal, product_sales, shipping_credits, promotional_rebates, 

sales_tax_collected, selling_fees, fba_fees, other_transaction_fees,other, total) 

from '/Users/manish/Downloads/amz.csv' delimiter ',' csv header

但它给出了以下错误:

错误:数字类型的无效输入语法:“-8,791.41” 上下文:复制 amz_payment1,第 23 行,列总计:“-8,791.41”

4

1 回答 1

1

“总计”列的类型为numeric,但 CSV 文件具有该位置的格式化字符串。您应该在表中添加一varcharmeta.amz_payment1并将信息复制到该列中。复制数据后,您可以使用UPDATE语句填充“总计”列:

ALTER TABLE meta.amz_payment1 ADD COLUMN total_fmt varchar;

\copy meta.amz_payment1("Date", ... total_fmt) from ...;

UPDATE meta.amz_payment1 SET total = total_fmt::numeric;

然后

ALTER TABLE meta.amz_payment1 DROP COLUMN total_fmt;
于 2015-05-13T08:29:51.150 回答