COPY(导入)数据到PostgreSQL数组列

时间:2012-06-23 14:03:22

标签: arrays postgresql postgresql-8.4

如何格式化(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'

1 个答案:

答案 0 :(得分:16)

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}}"
相关问题