【问题标题】:How to split the array and store into respected columns of table in Postgresql DataBase如何将数组拆分并存储到 Postgresql 数据库中表的尊重列中
【发布时间】:2013-12-19 06:03:44
【问题描述】:

我将元素数组 {idno,age,salary} 插入为{1,10000,30} 在 PostgreSQL 数据库中,我需要拆分并存储到表的受尊重的列中。

如何将拆分后的数组元素存储在表的列中?

首先这可能吗,如果可能的话,有人可以解释一下,我们该怎么做?

【问题讨论】:

  • 所以你在 PostgreSQL 中有一个包含这三个数字的数组,你想在某个表上update ... set idno=1, age=10000, salary=30
  • 谢谢,我正在将元素数组插入到某个表的受尊重列中。这三个数字插入到他们受尊重的列中。

标签: sql arrays postgresql postgresql-9.1 phppgadmin


【解决方案1】:

像这样?

insert into test(idno, age, salary)
select D[1], D[2], D[3]
from (select '{1,10000,30}'::int[]) as A(D);

sql fiddle demo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 2021-12-11
    • 2018-10-06
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    相关资源
    最近更新 更多