使用shell從DB2資料庫匯出資料

來源:互聯網
上載者:User

標籤:

使用shell指令碼根據輸入的使用者名稱,資料庫名,密碼從DB2資料庫匯出資料

(1)a.sh指令碼如下

#!/usr/bin/bashread -p "please input your DBNAME: " DBNAMEread -p "please input your username: " usernameread -p "please input your password: " passworddb2 connect to $DBNAME user $username using $passworddb2 "EXPORT to /home/Practice/data/a.del of del select * from A"

(2)串連Linux,使用下面命令執行

su - db2inst1 -c "/home/Practice/a.sh"

上面這條代碼是關鍵,其中a.sh檔案儲存體在/home/Practice路徑下

[[email protected] Practice]# chmod +x a.sh[[email protected] data]# su - db2inst1 -c "/home/Practice/a.sh"please input your DBNAME: oliverdbplease input your username: db2inst1please input your password: db2inst1   Database Connection Information Database server        = DB2/LINUXX8664 10.5.5 SQL authorization ID   = DB2INST1 Local database alias   = OLIVERDBSQL3104N  The Export utility is beginning to export data to file "/home/Practice/data/a.del".SQL3105N  The Export utility has finished exporting "2" rows.Number of rows exported: 2

到此處為止,資料已經從資料庫oiliverDB匯出到了目錄/home/Practice/data下。

 

使用shell從DB2資料庫匯出資料

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.