Oracle資料庫遠程匯入、匯出

來源:互聯網
上載者:User


exp本地匯出與imp本地匯入

exp命令:
1 exp username/psw@TEST file=d:test.dmp full=y
2 exp username/psw@TEST file=d:test.dmp owner=(ly)
3 exp username/psw@TEST file= d:test.dmp tables=(grid1,grid2)
1其中一是將Test(與某一資料庫對應的oracle服務名)資料庫進行整體匯出
2將屬於使用者ly的所有表匯出
3將表grid1,與grid2匯出
d:test.dmp是匯出的檔案地址

imp命令:
1 imp system/psw@TEST file=d:test.dmp
2 imp system/psw@TEST full=y file=d:test.dmp ignore=y
3 imp system/psw@TEST file=d:test.dmp tables=(grid1)ignore=y表示如果被匯入的資料庫中某個表已經存在就忽略不匯入那個表
3表示只匯入grid1這個表

在匯入匯出前要先測試下對應的資料庫是否是通的:tnsping test來測試,同樣test是服務名
所有命令可在cmd下執行


用exp/imp遠程操作資料庫

對ORACLE資料庫進行遠程操作,假設資料庫在192.168.1.110上,具體方法如下:
一、在用戶端建立和服務端對應的服務名
方法1:
修改tnsnames.ora檔案
加入遠程伺服器的命名:

Sql代碼
TEST_ORCL =  
(DESCRIPTION =  
    (ADDRESS_LIST =  
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))  
    )  
    (CONNECT_DATA =  
      (SERVICE_NAME = orcl)  
    )  
)

方法2:

在oracle用戶端,開啟net manager。

建立一個服務命名TEST_ORCL,主機IP為:192.168.1.110,服務名orcl,連接埠1521


二、測試遠程伺服器是否暢通

進入到cmd後,執行命令:tnsping TEST_ORCL。

三、遠程操作資料庫
匯出:

Sql代碼
1:exp username/password@TEST_ORCL file=bak_filepath
2:exp username/password@TEST_ORCL full=y file=bak_filepath
username 使用者名稱,password 密碼,TEST_ORCL 客服端服務名,bak_filepath 備份檔案存放的路徑

匯入:

Sql代碼
1:imp username/password@TEST_ORCL file=bak_filepath full=y
2:imp username/password@TEST_ORCL/database_name file=bak_filepath full=y
3:imp username/password@TEST_ORCL file=bak_filepath fromuser=fromadmin touser=toadmin

username 使用者名稱,password 密碼,TEST_ORCL 客服端服務名,bak_filepath 備份檔案存放的路徑
fromadmin 備份資料的使用者名稱,toadmin 還原資料庫的使用者名稱。database_name 還原到那個資料庫上

full=y 將資料庫整體匯出,包括表結構等。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.