gpt4 book ai didi

arrays - 将数据复制(导入)到 PostgreSQL 数组列中

转载 作者:行者123 更新时间:2023-11-29 11:13:51 27 4
gpt4 key购买 nike

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

最佳答案

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}}"

关于arrays - 将数据复制(导入)到 PostgreSQL 数组列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11170099/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com