通過excel向資料庫(ORACLE)裡插入資料,exceloracle

來源:互聯網
上載者:User

通過excel向資料庫(ORACLE)裡插入資料,exceloracle

大家都知道PL/SQL可以向excel複製資料,同樣我們也可以通過excel向資料庫裡插入資料。

下面我們以一個簡單的例子並配以示範

首先,我們建立一個表test

CREATE TABLE test(

id NUMBER

);

接著我們執行如下語句

SELECT * FROM test FOR UPDATE;


並點開的鎖


接著我們在excel裡複製一列數值型資料


選中PL/SQL查詢結果裡列名id,ctrl+v粘貼以上資料


點擊綠色箭頭

並commit提交即可完成向資料庫插入excel的資料這一任務

執行selext * from test;得到如所示結果



怎將excel檔案匯入到Oracle資料庫中

1、先把excel檔案轉換成csv或txt格式,使用oracle內建的工具SQL*Loader進行匯入。
2、把excel中的資料複製出來,在pl/sql developer中建立一個和excel資料一樣的表結構,進行粘貼就行了。
3、使用ODBC進行匯入。
 
怎將excel中的資料匯入到oracle資料庫中

1.準備資料:在excel中構造出需要的資料
2.將excel中的資料另存新檔文字檔(有定位字元分隔的)
3.將新儲存到文字檔中的資料匯入到pl*sql中
在pl*sql中選擇tools--text importer,在出現的視窗中選擇Data from Textfile,然後再選擇Open data file,
在彈出的檔案選擇框中選中儲存有資料的文字檔,此時將會看到data from textfile中顯示將要匯入的資料
4.在configuration中進行如下配置
注:如果不將Name in header勾選上會導致欄位名也當做記錄被匯入到資料庫中,從而導致資料錯誤
5.點擊data to oracle,選擇將要匯入資料的表,並在fields中將文本中的欄位與表中的欄位進行關聯
6.點擊import按鈕進行匯入
7.查看匯入的資料
OK,至此資料匯入成功。
 

相關文章

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.