I would like to bulk load a bunch of data into a Oracle database. I have written a program to easily format my data however I want. I see many examples of loading a csv file into Oracle, but they all require a control file for each table, linking it to one file.
It would be simple for me to create a script to generate all of the control files, however I would first like to know if it would be possibly to have all data in one file with table names designated in the data file?
For example:
"name1": "foo1",
"array1": [
{
name2: "foo2",
"array2" : [
{
"name3" : "foo3",
"array3": [
{
data : "ImData"
}
]
}
]
]
Disclaimer: This is a completely fictional database design and is not at all reflective of how I might store user data in the real world.
答案 0 :(得分:0)
您可以使用UTL_FILE读取CSV。这将使您完全控制如何处理其内容。但这确实意味着你会浪费大量的时间和精力来处理SQL * Loader的微薄而缓慢的实现。你为什么要那样做?
每个数据源和/或目标一个文件是CSV生成的公认约定。这是合同的必要部分。如果我们想要做任何其他事情,那么我们需要使用更合适的协议,例如XML或JSON,这些协议可以支持程序化审讯。
答案 1 :(得分:0)
为什么不使用SQLLdr?请参见SQLdr docs。请参阅“区分不同的输入记录格式”。
使用多个INTO表子句的好处
多个INTO TABLE子句使您能够:
将数据加载到不同的表中
从单个输入记录中提取多个逻辑记录
区分不同的输入记录格式
区分不同的输入行对象子类型
但是你必须在每一行指定表名(或它的ID)。 SQLLrd在行级工作,我担心它不支持节。
所以您可能需要将其更改为:
onefile.csv:
------------
details,1, John, john@gmail.com
details,2, Steve, steve@gmail.com
details,3, Sally, sally@gmail.com
account,1, John, johntheman, johnh43
account,2, Steve, password, steve.12
account,3, Sally, letmein, slllya2
这看起来像是对旧COBOL格式的回忆。