Oracle 中批量加载 UDT 列
我有一个具有以下结构的表:
create table my_table (
id integer,
point Point -- UDT made of two integers (x, y)
)
并且我有一个包含以下数据的 CSV 文件:
#id, point
1|(3, 5)
2|(7, 2)
3|(6, 2)
现在我想将此 CSV 批量加载到我的表中,但我找不到有关如何在 Oracle sqlldr 中处理 UDT 的任何信息
实用程序。当有 UDT 列时是否可以使用批量加载实用程序?
I have a table with the following structure:
create table my_table (
id integer,
point Point -- UDT made of two integers (x, y)
)
and i have a CSV file with the following data:
#id, point
1|(3, 5)
2|(7, 2)
3|(6, 2)
now i want to bulk load this CSV into my table, but i cant find any information about how to handle the UDT in Oracle sqlldr
util. Is is possible to use the bulk load util when having UDT columns?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道 sqlldr 是否可以做到这一点,但我个人会使用外部表。
将文件附加为外部表(该文件必须位于数据库服务器上),然后将外部表的内容插入到目标表中,同时将 UDT 转换为两个值。以下 select from Dual 应该可以帮助您进行翻译:
UPDATE
在 sqlldr 中,您可以使用标准 SQL 表达式转换字段:
上面的控制文件将提取字段中的第一个数字,如 (3, 4),但我找不到方法提取第二个数字 - 即我不确定是否可以将输入文件中的相同字段插入到两列中。
如果外部表不适合您,我建议 (1) 在加载之前使用 sed、awk、Perl 等转换文件,或者 (2) SQLLDR 将文件转换为临时表,然后使用第二个过程来转换文件数据并插入到最终表中。另一种选择是查看文件是如何生成的 - 您是否可以生成它,以便您需要转换的字段在文件中的两个字段中重复,例如:
也许其他人会用一种方法让 sqlldr 做什么你想要的。
I don't know if sqlldr can do this, but personally I would use an external table.
Attach the file as an external table (the file must be on the database server), and then insert the contents of the external table into the destination table transforming the UDT into two values as you go. The following select from dual should help you with the translation:
UPDATE
In sqlldr, you can transform fields using standard SQL expressions:
The control file above will extract the first digit in the fields like (3, 4), but I cannot find a way to extract the second digit - ie I am not sure if it is possible to have the same field in the input file inserted into two columns.
If external tables are not an option for you, I would suggest either (1) transform the file before loading, using sed, awk, Perl etc or (2) SQLLDR the file into a temporary table and then have a second process to trandform the data and insert into your final table. Another option is to look at how the file is generated - could you generate it so that the field you need to transform is repeated in two fields in the file, eg:
Maybe someone else will chip in with a way to get sqlldr to do what you want.
经过研究解决了这个问题,因为Oracle SQL*Loader有这个功能,并且是通过指定
列对象
来使用的,解决方案如下:Solved the problem after more research, because Oracle SQL*Loader has this feature, and it is used by specifying a
column object
, the following was the solution: