linux中oracle自动层数dataload

#!/bin/sh ##dataload ##dataload Table_name File_name colsep ##truncate/append/insert ##Home目录有 login.sh 文件,内容类似: sqlplus username/passwd@ORACLE_SID ##判断输入参数 if [ $# -eq 0 ]; then echo "" echo "------------------------dataload帮助文件!---------------------------" echo "要求:Home目录有 login.sh 文件,内容类似: sqlplus username/passwd@ORACLE_SID" echo "格式:dataload Table_name \"File_name\" colsep(默认:'|') " echo "例1:dataload wg_tp_1 \"Test 1.txt\" " echo "例2:dataload wg_tp_1 \"Test 1.txt\" \"|\"" echo "" exit 0; fi if [ $# -lt 2 ]; then echo "错误!没有参数或者参数不够!" echo "格式:dbload Table_name File_name colsep " exit 1; fi if [ $# -eq 2 ]; then echo "默认分隔符为:'|'"; colsep='|'; else colsep=$3; fi ##赋值变量 Table_name=$1 File_name=$2 LogInfo=`cat ~/login.sh|grep sqlplus|awk '{print$2}'` ##得到字段函数 get_col() { sqlplus -s $LogInfo temp.ctl echo "Load data" >> temp.ctl echo "infile \""$File_name"\"" >> temp.ctl echo $load_type>> temp.ctl echo "into table "$Table_name >> temp.ctl echo "fields terminated by \""$colsep"\"" >> temp.ctl echo "trailing nullcols (" >> temp.ctl ##get_col $Table_name|sed -n '1,2!'p |sed -n '$!'p |sed -n '$!'p|awk '{print$1","}' >> temp.ctl ##get_col $Table_name|sed -n '1,2!'p |sed -n '$!'p |sed -n '$p'|awk '{print$1}' >> temp.ctl ####get_col $Table_name|sed -n '1,2!'p |sed '/^$/d' |awk '{print$1","}' |sed '$s/,//' >> temp.ctl get_col $Table_name|sed -n '1,2!'p |sed '/^$/d' |awk '{print$1","$2}'|GetDate|sed '$s/,//' >> temp.ctl echo ")" >> temp.ctl ##sqlldr ... control=temp.ctl rows=10000 bindsize=88888888 echo " " echo " " echo " " echo "运行:" echo "sqlldr \`cat ~/login.sh|grep sqlplus|awk '{print\$2}'\` control=temp.ctl rows=10000 " . /etc/profile if sqlldr `cat ~/login.sh|grep sqlplus|awk '{print$2}'` control=temp.ctl rows=10000 ; then echo "导入完毕!"; else echo "导入有误,请查看导数日志!"; fi echo "END!"

你可能感兴趣的:(oracle,linux)