Arrays 将数据复制(导入)到PostgreSQL数组列中
(CSV?)文本文件应如何格式化,以便可以导入(使用Arrays 将数据复制(导入)到PostgreSQL数组列中,arrays,postgresql,postgresql-8.4,Arrays,Postgresql,Postgresql 8.4,(CSV?)文本文件应如何格式化,以便可以导入(使用COPY?)到PostgreSQL(8.4)表中的数组列中 给定表testarray: Column | Type | ---------+-------------------------| rundate | date | runtype | integer | raw | double precision[]
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)[] |
及
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'
请注意,这是默认格式,但您可以选择覆盖默认引号字符。
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'
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}}"