16

应该如何格式化(CSV?)文本文件,以便可以将其导入(使用COPY?)到 PostgreSQL(8.4)表中的数组列中?

给定表testarray

 Column  |          Type           |
---------+-------------------------|
 rundate | date                    | 
 runtype | integer                 | 
 raw     | double precision[]      | 
 labels  | character varying(16)[] | 
 results | double precision[]      | 
 outcome | character varying(8)[]  | 

COPY testarray from '/tmp/import.txt' CSV

没有以下import.txt工作内容:

2010/06/22,88,{{1,2},{3,4}},{{1,2},{3,4}},{{1,2},{3,4}},{{1,2},{3,4}}
2010/06/22,88,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4
2010/06/22,88,'{{1,2},{3,4}}','{{1,2},{3,4}}','{{1,2},{3,4}}','{{1,2},{3,4}}'
2010/06/22,88,'1,2,3,4','1,2,3,4','1,2,3,4','1,2,3,4'
4

1 回答 1

22
COPY testarray from '/tmp/import.txt' CSV

2010-06-22,88,"{{1,2},{3,4}}","{{1,2},{3,4}}","{{1,2},{3,4}}","{{1,2},{3,4}}"
于 2012-06-23T14:28:14.107 回答