我有一个文本文件dbim.txt,是通过alert log生成的,内容如下:
2020-09-11
2020-09-11
...
2023-12-03
2023-12-03
2023-12-26
我已经在Oracle数据库中建立了目标表:
create table dbim(a varchar(16));
我想把日志文件导入Oracle数据库里的表中,希望用简单快速的方法。这里的快速不是指导入速度,而是指操作简单,不用做太多配置。
SQL*Loader Express不需要写控制文件,对输入文件有要求,但是我们的日志文件正好符合。详见这里。
过程如下:
$ sqlldr ssb@orclpdb1 table=dbim data='dbim.txt'
Password:
SQL*Loader: Release 23.0.0.0.0 - Production on Fri Jan 5 01:50:44 2024
Version 23.3.0.23.09
Copyright (c) 1982, 2023, Oracle and/or its affiliates. All rights reserved.
Express Mode Load, Table: DBIM
Path used: External Table, DEGREE_OF_PARALLELISM=AUTO
Table DBIM:
158971 Rows successfully loaded.
Check the log files:
dbim.log
dbim_%p.log_xt
for more information about the load.
更简洁的命令如下,但数据文件必须命名为dbim.dat:
sqlldr ssb@orclpdb1 table=dbim
有几个需要注意的地方。
$ pwd
/home/oracle/test
$ sqlldr ssb@orclpdb1 table=dbim
Password:
SQL*Loader: Release 23.0.0.0.0 - Production on Fri Jan 5 01:52:03 2024
Version 23.3.0.23.09
Copyright (c) 1982, 2023, Oracle and/or its affiliates. All rights reserved.
Express Mode Load, Table: DBIM
Path used: External Table, DEGREE_OF_PARALLELISM=AUTO
SQL*Loader-807: error loading table
ORA-29913: error while processing ODCIEXTTABLEOPEN routine
ORA-29400: data cartridge error
KUP-04040: file dbim.dat in SYS_SQLLDR_XT_TMPDIR_00000 not found
Help: https://docs.oracle.com/error-help/db/ora-29913/
Table DBIM:
0 Rows successfully loaded.
Check the log files:
dbim.log
dbim_%p.log_xt
for more information about the load.