关闭。这个问题需要details or clarity .它目前不接受答案。
想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.
7年前关闭。
Improve this question
我尝试使用sql loader。问题是数据加载时表需要为空。有没有办法在不截断表的情况下进行数据上传。需要将CSV数据附加到表中。我使用的是oracle 11g。
最佳答案
When you are loading a table, you can use the
INTO TABLE
clause to specify a table-specific loading method (INSERT
,APPEND
,REPLACE
, orTRUNCATE
) that applies only to that table. That method overrides the global table-loading method. The global table-loading method isINSERT
, by default, unless a different method was specified before anyINTO TABLE
clauses.
所以默认情况下你的表加载将在
INSERT
模式,这确实要求表为空。文档还解释了 how to load data into a non-empty table ;在您的情况下,您要保留现有数据:
APPEND
If data already exists in the table, then SQL*Loader appends the new rows to it. If data does not already exist, then the new rows are simply loaded. You must haveSELECT
privilege to use theAPPEND
option.
所以你的控制文件需要这样写(如图所示 in their example ):
LOAD DATA
INFILE 'my_file.dat'
BADFILE 'my_file.bad'
DISCARDFILE 'my_file.dsc'
APPEND
INTO TABLE my_table
...
您还可以考虑使用新的 CSV 数据作为 external table并从中插入到您的真实表中,这可能会更灵活一些。
关于oracle - 从命令行将数据从 csv 文件加载到 oracle 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21279194/