Oracle 下匯入txt的shell指令碼以及配置

來源:互聯網
上載者:User

首先有一個info.txt檔案,檔案內容其中一條是如下的情況

FFF_GGG_FF|GOD|254|254|16384|16384|254|254|

接下來先是在Oracle中建立相應的表,結構如下:

SQL> desc info;
TABLENAME VARCHAR2(200)
OWNUSER VARCHAR2(100)
EXPNUMS NUMBER(12)
EXPLOGNUMS NUMBER(12)
EXPSIZE NUMBER(12)
IMPSIZE NUMBER(12)
IMPLOGNUMS NUMBER(12)
IMPNUMS NUMBER(12)

接下來配置匯入的控制檔案info.ctl

load data
infile 'info.txt'
append into table info
fields terminated by '|'
(
TABLENAME,
OWNUSER,
EXPNUMS,
EXPLOGNUMS,
EXPSIZE,
IMPSIZE,
IMPLOGNUMS,
IMPNUMS
)

接下來是info.sh的指令碼

#!/bin/bash

sqlldr senwei/senwei control=$HOME/oracle/info.ctl

哎呀 其實就一句命令,真不好意思……

還有一句就是想把info.txt轉換為excel格式,然後在windows開啟。但是在linux環境下執行的語句

cat exp_imp_report.list|sed 's/|/\t/g' >aa.xls

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.