如何将值插入到 postgresql 中已有的表中?
我在 postgresql 中有一个名为 order_facts 的现有表。
运行 select * from order_facts
会得到这个: 如您所见,order_date 为空,我想用另一个表中的数据填充它。 为此,我使用了以下代码:
insert into order_facts(order_date)
select day_key
from "Day" as d, orders as o
where d.fulldate = o.order_date;
但这会在表格底部附加 day_key 值像这样< /a> 我应该在插入命令中更改什么才能让它开始从第 1 行而不是行尾插入 day_key?
I have an already existing table in postgresql called order_facts.
Running select * from order_facts
gets you this:
as you can see order_date is null and I'd like to populate it with data from another table.
To do that i used the following code:
insert into order_facts(order_date)
select day_key
from "Day" as d, orders as o
where d.fulldate = o.order_date;
But this appends the day_key values at the bottom of the table like so
What do I change in my insert command to get it to start inserting the day_key from row 1 and not the end of the row?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
UPDATE
而不是INSERT
。例如
You need to use
UPDATE
instead ofINSERT
.e.g.