Postgres COPY two files to same table with source indication?

末鹿安然 提交于 2021-01-29 18:23:57

问题


I'm using Postgres 12.

I have 2 files that I want to load into a table via COPY. However, I need the rows from each file to indicate their source. Is there some trick with COPY where I could specify a default value for a column? I can't use the DEFAULT mechanism on the table declaration itself since that'd be universal, not different per file.

The only hack I've come up with so far is running the files through a pre-step to add the column to the raw file, but that's painful as I'm trying to load it directly from S3 without creating intermediate copies (and slow given the file sizes).

来源:https://stackoverflow.com/questions/63905091/postgres-copy-two-files-to-same-table-with-source-indication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!