ORACLE匯入匯出操作篇

來源:互聯網
上載者:User

標籤:style   ar   io   color   os   使用   sp   on   檔案   

1. DIRECTORY

指定轉儲檔案和記錄檔所在的目錄
DIRECTORY=directory_object
Directory_object用於指定目錄對象名稱.需要注意,目錄對象是使用CREATE DIRECTORY語句建立的對象,而不是OS目錄

create or replace directory DUMPDIR as ‘/home/oracle/hpdata‘;
Grant read,write on directory DUMPDIR to ics;

2. CONTENT

該選項用於指定要匯出的內容.預設值為ALL
CONTENT={ALL | DATA_ONLY | METADATA_ONLY}
當設定CONTENT為ALL時,將匯出對象定義及其所有資料.為DATA_ONLY時,只匯出對象資料,為METADATA_ONLY時,只匯出對象定義

expdp ics/ics directory=DUMPDIR dumpfile=ics.dmp content=metadata_only
----------只匯出對象定義
expdp ics/ics directory=DUMPDIR dumpfile=ics.dmp content=data_only
----------匯出出所有資料

3. DUMPFILE

用於指定轉儲檔案的名稱,預設名稱為expdat.dmp
DUMPFILE=[directory_object:]file_name [,….]
Directory_object用於指定目錄對象名,file_name用於指定轉儲檔案名稱.需要注意,如果不指定directory_object,匯出工具會自動使用DIRECTORY選項指定的目錄對象
show parameter dump;--查看變數

expdp ics/ics directory=DUMPDIR dumpfile=ics.dmp

impdp oracle/oracle DIRECTORY=DUMPDIR DUMPFILE=ics_141124_1.dmp remap_schema=ics:ics TABLE_EXISTS_ACTION=REPLACE

4、資料泵匯出的各種模式:

(1)、 按表模式匯出:
expdp ics/ics tables=fntaccinfo,fntaccbalhis,fntaccjrnl dumpfile =ics_tables.dmp logfile=ics_tables.log directory=DUMPDIR job_name=my_job

(2)、按查詢條件匯出:
expdp ics/ics tables=ics.membaseinfo dumpfile =ics_membaseinfo.dmp logfile=ics_membaseinfo.log directory=DUMPDIR job_name=my_job query=‘"where ci_typ=‘0‘"‘

(3)、按資料表空間匯出:
Expdp ics/ics dumpfile=expdp_tablespace.dmp tablespaces=USER logfile=expdp_tablespace.log directory=DUMPDIR job_name=my_job

(4)、匯出方案
Expdp ics/ics DIRECTORY=DUMPDIR DUMPFILE=schema.dmp SCHEMAS=ICS,HPDM

(5)、匯出整個資料庫:
expdp ics/icsics dumpfile =ics_141124_1.dmp full=n logfile=full.log directory=DUMPDIR job_name=my_job --加一個 compression=ALL 可以壓縮備份 但是還原的時候會更耗時

----------------------------------------------------------------------------------------------------------------------

impdp匯入模式:

1、按表匯入
p_street_area.dmp檔案中的表,此檔案是以gwm使用者按schemas=gwm匯出的:
impdp gwm/[email protected] dumpfile =p_street_area.dmp logfile=imp_p_street_area.log directory=dir_dp tables=p_street_area job_name=my_job

2、按使用者匯入(可以將使用者資訊直接匯入,即如果使用者資訊不存在的情況下也可以直接匯入)
impdp gwm/[email protected] schemas=gwm dumpfile =expdp_test.dmp logfile=expdp_test.log directory=dir_dp job_name=my_job

3、不通過expdp的步驟產生dmp檔案而直接匯入的方法:
--從來源資料庫中向目標資料庫匯入表p_street_area
impdp gwm/gwm directory=dir_dp NETWORK_LINK=igisdb tables=p_street_area logfile=p_street_area.log job_name=my_job
igisdb是目的資料庫與來源資料的連結名,dir_dp是目的資料庫上的目錄

4、更換SCHEMA

--匯出gwm使用者下的所有資料
expdp ics/ics directory=DUMPDIR dumpfile=ics.dmp SCHEMAS=ics
註:如果是用sys使用者匯出的使用者資料,包括使用者建立、授權部分,用自身使用者匯出則不含這些內容
--以下是將ics使用者下的資料全部匯入到使用者hpdm(原來為gmapdata資料表空間下)下
impdp hpdm/hpdm directory=DUMPDIR dumpfile=ics.dmp remap_schema=ICS:HPDM

5、更換TABLESPACE
採用remap_tablespace參數

-----------------------------------
create user test identified by test default tablespace users;
grant resource to test;
grant connect to test;
grant dba to test;


sqlplus "/as sysdba"

create directory DUMPDIR as ‘/home/oracle/hpdata‘;
Grant read,write on directory DUMPDIR to test;

------------------------------------------------
不同schema資料整庫備份恢複(需要先刪除目標庫)
impdp test/test DIRECTORY=DUMPDIR DUMPFILE=hp66_20140704.dmp remap_schema=HPDM:TEST FULL=Y IGNORE=Y
整庫匯出備份
expdp ics/ics schemas=ICS dumpfile=ics20140704.dmp DIRECTORY=DUMPDIR

---如果表存在則更新資料,適用於資料結構不發生變化,僅僅將資料恢複到某個備份,但預存程序、視圖、函數、sequence更新會失敗
impdp test/test DIRECTORY=DUMPDIR DUMPFILE=ics20140704.dmp remap_schema=ICS:TEST table_exists_action=replace;
---基本同上,但不會執行預存程序、視圖、函數、sequence的更新
impdp test/test DIRECTORY=DUMPDIR DUMPFILE=hp66_20140704.dmp remap_schema=HPDM:TEST table_exists_action=replace EXCLUDE=SEQUENCE,VIEW,FUNCTION,PROCEDURE;

ORACLE匯入匯出操作篇

聯繫我們

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