Oracle EXP和IMP

來源:互聯網
上載者:User

Exp/Imp是普遍使用的邏輯備份方式

 

使用Exp/Imp工具的情境

1、 兩個資料庫之間傳送資料,可以不同資料庫版本,不同作業系統

2、 資料庫的備份和恢複

3、 從一個資料庫使用者傳到另一個資料庫使用者

4、 從一個資料表空間傳到領一個資料表空間

 

在sqlplus中設定顯示資料的長度大小

colcol_name for a50;

 

查看資料檔案名和對應的資料表空間

col file_name for a50;

col tablespace_name for a15;

select file_name,tablespace_name from dba_data_files;

 

建立一個資料表空間

create tablespace bank_tbs

datafile 'C:\APP\DRAGON\ORADATA\ZLPXB\BANK_DATA02.DBF'

size 5M autoextend maxsize10G;

 

建立使用者使用該資料表空間

createuser bankuser identified by Oracle

default tablespace bank_tbs;

grant connect,resource to bankuser;

 

使用bankuser登陸資料庫並建立表

createtable dept

(

deptno number(2) constraint pk_dept PrimaryKey,

dname varchar2(14),

loc varchar2(13)

);

insert into dept values(10,'accounting','new york');

commit;

 

查看使用者使用的資料表空間

select tablespace_name from user_tables;

 

測試exp、imp

exp bankuser/oracle@zlpxb file=D:\bankuser.dmp log=D:\bankuserExp.log

drop table dept;

select * from dept;

imp bankuser/oracle@zlpxb fromuser=bankuser touser=bankuser file=D:\bankuser.dmp log=D:\bankuserImp.log

select * from dept;

 

 

實際工作中用的最多的匯出命令

exp userid=sys/sys@orcl BUFFER=8192 FILE=x:\*.dmp LOG=x:\*.log full=y grants=y

 

實際工作中用的最多的匯入命令

imp userid=sys/sys@orcl BUFFER=81920 FILE=x:\*.dmp LOG=x:\*.log full=y grants=y ignore=y


 

 

使用expdp、impdp遷移資料

expdp、impdp可以看做是exp、imp的升級版,兩者主要區別如下:

1、 emp和imp是用戶端工具程式,但他們可以在用戶端和服務端都可以使用。

2、 expdp和impdp是服務端的工具程式,只能在服務端使用,遷移速度比較快。

 

測試expdp、impdp

create directory dir_dpas'D:\';

grant read,write on directory dir_dp to bankuser;

expdp bankuser/oracle@zlpxbdirectory=dir_dp dumpfile=bankuserdp.dmp logfile=bankuserdp.log

drop table dept;

select * from dept;

impdp bankuser/oracle@zlpxbdirectory=dir_dp dumpfile=bankuserdp.dmp logfile=bankuserimpdp.log

select *from dept;

 

 

在Linux下使用expdp、impdp

create or replace directory expdp_dir as '/home/oracle/expdp_dir';

mkdir expdp_dir

chmod 777 expdp_dir

expdp bankuser/oracle@zlpxb directory=expdp_dir dumpfile=Linux.dmp logfile=Linuxdmp.log

 

 

 

 

資料泵匯出的方法有多種,這裡我們只介紹兩種:

Ø 單個使用者方案匯出

Expdp [使用者名稱]/[密碼]@[主機字元竄] schemas=[使用者名稱] dumpfile=X.dmp logfile=X.log directory=expdp_dir

Ø 資料庫全庫匯出

Expdp [使用者名稱]/[密碼]@[主機字元竄] full=y dumpfile=X.dmp logfile=X.log directory=expdp_dir

² 資料泵匯入

按以上匯出方式:

Ø 單個使用者方案匯入

impdp [使用者名稱]/[密碼]@[主機字元竄] schemas=[使用者名稱] dumpfile=X.dmp logfile=X.log directory=expdp_dir ignore=y

Ø 資料庫全庫匯入

impdp [使用者名稱]/[密碼]@[主機字元竄] full=y dumpfile=X.dmp logfile=X.log directory=expdp_dir ignore=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.