oracle - 从命令行将数据从 csv 文件加载到 oracle 表

标签 oracle oracle11g sql-loader data-import

关闭。这个问题需要details or clarity .它目前不接受答案。












想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.

7年前关闭。




Improve this question




我尝试使用sql loader。问题是数据加载时表需要为空。有没有办法在不截断表的情况下进行数据上传。需要将CSV数据附加到表中。我使用的是oracle 11g。

最佳答案

SQL*Loader documentation说:

When you are loading a table, you can use the INTO TABLE clause to specify a table-specific loading method (INSERT, APPEND, REPLACE, or TRUNCATE) that applies only to that table. That method overrides the global table-loading method. The global table-loading method is INSERT, by default, unless a different method was specified before any INTO 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 have SELECT privilege to use the APPEND 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/

相关文章:

oracle - 如何检查程序包中是否存在程序?

sql - Oracle regexp_substr - 如何提取不包括标记字符的文本

oracle - 选择整个分区使用索引 - 为什么?

oracle - 无法将大 double 存储到 Oracle 中(ORA-01426 : numeric overflow)

windows - SQL 加载程序 : writing batch file (windows) for processing multiple data file

oracle - 安装 sql loader linux

linux - oracle 瘦 jdbc 连接在不活动后接收 "connection reset"

java - 批量更新异常 : the batch will not terminate

sql - ORA-01873 : the leading precision

regex - 在 Linux 中移动 csv 文件的换行问题