我正在使用 CTL 文件将存储在文件中的数据加载到我的 Oracle 数据库中的特定表中。目前,我使用以下命令行启动加载程序文件:
sqlldr user/pwd@db data=my_data_file control=my_loader.ctl
我想知道是否可以使用指定参数在 CTL 文件中检索。
此外,是否可以检索 CTL 用于填充表的数据文件的名称?我还想为每一行插入它。我目前必须调用一个程序来更新以前插入的记录。
任何帮助,将不胜感激 !
据我所知,没有任何方法可以在 ctrl 中将参数作为变量传递。
但是您可以在 ctl 中使用常量并修改 clt 文件以更改每个加载时间的常量值(在 ctl 文件内容中)。
编辑:更具体。
my_loader.ctl:
--options
load data
infile 'c:\$datfilename$' --this is optional, you can specify here or from command line
into table mytable
fields....
(
datafilename constant '$datfilename$', -- will be replace by real datafname each load
datacol1 char(1),
....
)
dataload.bat:假设 $datfilename$ 是文本将被数据文件的名称替换。
::sample copy
copy my_loader.ctl my_loader_temp.ctl
::replace the name of datafile (mainly the content to load into table's data column)
findandreplace my_loader_temp.ctl "$datafilename$" "%1"
::load
sqlldr user/pwd@db data=%1 control=my_loader_temp.ctl
::or with data be obmitted if you specified by infile in control file.
sqlldr user/pwd@db control=my_loader_temp.ctl
使用:dataload.bat mydatafile_2010_10_10.txt