1、表test_member结构是 name,code,department
2、dept1.txt文件的内容是:
技术部
张三;2013123
李四;2013234
王五;2013345 dept2.txt文件的内容是:
采购部
陈六;2013123
赵七;2013234
孙八;20133453、我的想法是,在ctl控制文件中,用类似case when的条件判断来实现,表中的department根据不同txt赋不同值,类似这样:
load data
characterset al32utf8
infile "D:\dept1.txt"
infile "D:\dept2.txt"
into table test_member(
name terminated by ';',
code terminated by whitespace
department constant ( case when infile="D:\dept1.txt" then "技术部" when infile="D:\dept2.txt" then "采购部" else "" end)
)
上面这个case when是我瞎猜的,所以请大神帮忙看看,我想实现sqlldr根据不同的infile如何对表字段赋不同的默认值,改如何实现?如果我这种case when的想法可行,那控制文件该如何编写呢?
2、dept1.txt文件的内容是:
技术部
张三;2013123
李四;2013234
王五;2013345 dept2.txt文件的内容是:
采购部
陈六;2013123
赵七;2013234
孙八;20133453、我的想法是,在ctl控制文件中,用类似case when的条件判断来实现,表中的department根据不同txt赋不同值,类似这样:
load data
characterset al32utf8
infile "D:\dept1.txt"
infile "D:\dept2.txt"
into table test_member(
name terminated by ';',
code terminated by whitespace
department constant ( case when infile="D:\dept1.txt" then "技术部" when infile="D:\dept2.txt" then "采购部" else "" end)
)
上面这个case when是我瞎猜的,所以请大神帮忙看看,我想实现sqlldr根据不同的infile如何对表字段赋不同的默认值,改如何实现?如果我这种case when的想法可行,那控制文件该如何编写呢?
谢谢帮忙出主意。
我的txt文件比较多 有上百个,一个txt一个控制文件,控制文件我也要写上百个。我跟你的第2个方法想法差不多,现在卡在这了,我想通过批处理,把每个txt文件中,每行的最右侧拼接上第一行的内容。例如把每个txt由下面这个格式: 技术部
张三;2013123
李四;2013234
王五;2013345通过批处理弄成这个样式:
技术部;技术部
张三;2013123;技术部
李四;2013234;技术部
王五;2013345;技术部现在就是不知道这个批处理改怎么写