gpt4 book ai didi

带有递归复制到的Postgresql

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

在 WITH RECURSIVE 查询中,是否可以像 INSERT INTO 一样使用 COPY TO?

我正在尝试通过递归查询写入文件,而不必先将其保存到表中。

最佳答案

为什么不呢,例如:

t=# copy ( WITH RECURSIVE t(n) AS (
VALUES (1)
UNION ALL
SELECT n+1 FROM t WHERE n < 100
)
SELECT sum(n) FROM t) to '/tmp/rc';
COPY 1
Time: 5.161 ms
t=# \! cat /tmp/rc
5050

关于带有递归复制到的Postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46852331/

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