Oracle資料庫中表的imp&exp

來源:互聯網
上載者:User

標籤:ima   com   evel   taf   extent   def   color   暫存資料表   檔案   

  在Oracle資料庫中可以使用imp和exp命令來執行資料的匯入匯出(包括表結構和資料),使用imp和exp命令執行匯入匯出操作必需的是需要安裝Oracle資料庫,系統安裝Oracle資料庫,可以識別 dmp  /  imp 命令,否則系統會不識別imp和exp命令,如下左圖所示:

  裝好Oracle後,使用資料庫連接工具串連好資料庫(我自己使用的是sqldeveloper),執行匯入匯出命令:

匯出:

1. 開啟cmd;

2. 執行命令。命令格式:exp 使用者名稱/密碼@資料庫IP地址/實力名 file=匯出檔案路徑\檔案名稱.dmp owner=使用者名稱

例如:exp CUSTOMER_SERVICE_ROOT/[email protected]/fdms2 file=C:\Users\Administrator\Desktop\20180202.dmp owner=CUSTOMER_SERVICE_ROOT   此處的fdms2是資料庫名,此處匯出的是整個資料庫,若有選擇性的匯出部分表結構和資料則執行下面的命令:

  exp CUSTOMER_SERVICE_ROOT/[email protected]/fdms2  file=C:\Users\Administrator\Desktop\20180202.dmp tables=(AAAA,BBBB)  

注意:在執行匯出整個資料庫時,有些表是空表,沒有資料,匯出資料時,空表是不會被執行匯出的,此時需要對空表做一定的處理:

1. 執行sql  :select table_name from user_tables where NUM_ROWS=0;
select ‘alter table ‘||table_name||‘ allocate extent;‘ from user_tables where num_rows=0;

2. 將步驟1中執行的sql結果複製繼續執行,然後執行匯出命令即可匯出表結構和資料。

匯入:

1.--DBCA 建立Orcl執行個體

2. --資料庫連接工具 sys使用者登入

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.--建立暫存資料表空間(可不做)
create temporary tablespace myth_temp tempfile ‘C:\Oracle_space\myth_temp_20171116.dbf‘
size 100m autoextend on next 50m maxsize 200m;

4.--建立資料表空間
create tablespace myth datafile ‘C:\Oracle_space\myth_20171116.dbf‘
size 200m autoextend on next 100m maxsize 400m;

 

5--擴充資料表空間(輔助操作,可不做)
alter tablespace myth add datafile ‘C:\Oracle_space\myth_20171116.dbf‘
size 200m autoextend on;

6--建立使用者並制定資料表空間
create user username identified by 123456 default tablespace myth
temporary tablespace myth_temp

 

7.--賦權
grant dba to username

8.--WIN + R

9.--CMD

10.--匯入命令

imp 新使用者名稱/密碼@執行個體名 file=dmp檔案路徑\檔案名稱.dmp fromuser=匯出時的使用者名稱 touser=新使用者名稱

imp uwp_cfgh_root/[email protected] file=C:\server\201711088.dmp fromuser=uwp_cfgh_root touser=uwp_cfgh_root

 

若執行匯入部分表結構和資料則用下面的命令:

 imp CUSTOMER_SERVICE_ROOT/[email protected]/fdms2  file=C:\Users\Administrator\Desktop\20180202.dmp  tables=(AAAA,BBBB);

 

 

參考文檔地址:http://blog.csdn.net/micholas_net/article/details/78714589          

                         http://blog.csdn.net/menghuannvxia/article/details/51076930

 

Oracle資料庫中表的imp&exp

聯繫我們

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