如何从csv文件更新表? [英] How to UPDATE table from csv file?
问题描述
如何在PostgreSQL中从csv文件更新表? (版本9.2.4)
How to update table from csv file in PostgreSQL? (version 9.2.4)
复制命令用于插入.但是我需要更新表.如何从没有临时表的csv文件更新表?
我不想从csv文件复制到临时表并从临时表更新表.
没有像Oracle这样的合并命令吗?
Copy command is for insert. But I need to update table. How can I update table from csv file without temp table?
I don't want to copy to temp table from csv file and update table from temp table.
And no merge command like Oracle?
推荐答案
简单而快速的方法是使用临时登台表,如以下密切相关的答案中所述:
如何使用来自Postgres中CSV文件的值?
The simple and fast way is with a temporary staging table, like detailed in this closely related answer:
How to update selected rows with values from a CSV file in Postgres?
如果您出于某些未知原因不希望"这样做,则还有更多方法:
If you don't "want" that for some unknown reason, there are more ways:
A foreign data wrapper with
file_fdw
.
You can runUPDATE
commands directly using this one.
pg_read_file().对于特殊用例.
此相关答案中的详细信息:
从触发器内的文本文件中读取数据
Details in this related answer:
Read data from a text file inside a trigger
Postgres中没有MERGE
命令,对于COPY
则更少.
关于是否以及如何添加的讨论正在进行中.有关详细信息,请查看 Postgres Wiki .
There is no MERGE
command in Postgres, even less for COPY
.
Discussion about whether and how to add it is ongoing. Check out the Postgres Wiki for details.
这篇关于如何从csv文件更新表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!