PostgreSQL 如何创建一组表示值矩阵的条目?
拓扑基域还有x
、y
、z
、gradient
、tmestamp
,用户
现在我面临着用数据填充我的基地的问题。我有几个具有相同特征但位置不同的补丁。 我通过准备一条插入语句和两个嵌套循环来解决这个问题,这些循环改变了x
,y
(z
在填充策略时被修复(至少目前,
编程方法很慢,非常慢,所以我尝试用 SQL 来玩它,我已经做到了:
insert into topo12 ("x","y","z","gradient","user","refresh")
select generate_series(2,4),generate_series(2,4),1024,12222563,'toto',1234567878;
但这并没有给出(逻辑上我知道但是......)一个矩阵,而是一个向量。 到目前为止,我正在努力让进一步的子请求发挥作用,因此任何提示都值得赞赏。
Still a topological base fields are x
, y
, z
, gradient
, tmestamp
, user
now I am at the problem of populating my base with data. I have several patches that have the same characteristic, but a different position.
I solved it with preparing an insert statement and two nested loops varying the x
, y
(z
being fixed when filling up a strate (at least at the moment).
Programmatical approach is slow, very slow so I tried to play it in SQL and I got that far:
insert into topo12 ("x","y","z","gradient","user","refresh")
select generate_series(2,4),generate_series(2,4),1024,12222563,'toto',1234567878;
But that doesn't give (logical I know but...) a matrix, but a vector
and so far I am struggling with getting further sub-requests working, so any hint appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你想要的是一个连接,这样你就可以生成两个系列的笛卡尔积:
你当前正在同时从两个集合返回函数中进行选择。我不明白它的语义应该是什么,但它不会产生您可能想要的值的笛卡尔积:
I think what you want is a join, so you can produce a Cartesian product of two series:
You're currently selecting from two set-returning functions at once. I don't understand what the semantics of that are supposed to be, but it's not producing a Cartesian product of values like you probably want: