資料庫幫浦(expdp impdp)匯入匯出流程

2021-09-22 09:33:02 字數 3032 閱讀 1034

一、 資料庫的匯出(expdp)

建立預設匯出目錄

sql>create directory [dirname] as 『[dirpath]』;
賦予指定使用者在此目錄的讀寫許可權

sql>grant read, write on directory [dirname] to [dbuser];
使用expdp匯出資料庫

① 匯出完整schema

> expdp [username/passwd] dumpfile=[dmpname].dmp directory=[directory_name] schemas=[schema_name]
② 匯出除表以外的部分資料物件

可通過exclude引數排除無需匯出的資料物件,如:

>expdp [username/passwd] dumpfile=[dmpname].dmp directory=[directory_name] logfile=[logname.log] exclude=[object_type]:」in (『name_clause』,』 name_clause』,…)」, [object_type],…

example:

>expdp scott/tiger directory=dump_dir dumpfile=exc1.dmp logfile=exc1.log exclude=table:\」in \(\『emp\』,\』dept\』\)\」,view

其中單引號中的內容必須用大寫才能生效

其他資料物件以此類推

③ 匯出若干張表和若干張資料物件

>expdp [username/passwd] dumpfile=[dmpname].dmp directory=[directory_name] logfile=[logname.log] include=[object_type]:」in (『name_clause』,』name_clause』,…)」,[object_type],…
example:

>expdp scott/tiger directory=dump_dir dumpfile=exc1.dmp logfile=exc1.log include=table:\ 「in (\『emp\』,\』dept\』\)\」,view:\」in \(\『v\_emp\』\)\」,procedure
二、將匯出的檔案通過scp傳到需要匯入的伺服器上
example:

>scp * [email protected]:/data/dpdump
三、 將dmp檔案匯入到指定庫中
建立預設匯出目錄

sql>create directory [dirname] as 『[dirpath]』;

2. 賦予指定使用者在此目錄的讀寫許可權

sql>grant read, write on directory [dirname] to [dbuser];

使用impdp工具匯入

① 匯入完整schema

用dba許可權登陸,指定schema進行全庫匯入

>impdp [dba_user/passwd] directory=[directory_name]dumpfile=[dumpfile_name].dmp logfile=[logfile_name].log schemas=[schema_name]
如果想要更新已經存在的表則可以進行如下操作

② 匯入除表以外的部分資料物件

>impdp [dba_user/passwd] directory=[directory_name]dumpfile=[dumpfile_name].dmp logfile=[logfile_name].log schemas=[schema_name] exclude=table, [object_type]:」in (『name_clause』),(『name_clause』),…」,…

example:

>impdp system/oracle directory= dump_dir dumpfile=fulldb.dmp logfile=full_imp.log schemas=scott exclude =table,view:\」in \(\『v\_bonus\』\)\」

③ 匯入若干張表和若張資料物件

>impdp [dba_user/passwd] directory=[directory_name]dumpfile=[dumpfile_name].dmp logfile=[logfile_name].log schemas=[schema_name] include=[object_type]:」in (『name_clause』),(『name_clause』),…」, [object_type]:」in (『name_clause』),(『name_clause』),…」,…

example:

> impdp system/oracle directory=dump_dir dumpfile=fulldb.dmp logfile=full_imp.log schemas=scott include=table:\"in \(\'emp\',\'dept\'\)\",view:\"in \(\'v\_emp\',\'v\_dept\'\)\"
四、注意事項

如果匯出的是指定模式下所有的資料對像,則想獲得指定的資料物件時需在impdp中進行引數指定。

如果匯出的是指定模式下的指定的資料物件,則impdp時無需指定可選引數。

補充:僅匯出資料庫結構

impdp system/oracle directory=dump_dir dumpfile=fulldb.dmp logfile=full_imp.log schemas=scott content=metadata_only

Oracle之expdp impdp資料幫浦匯入匯出

寫在前面 工作中碰到資料庫伺服器需要遷移,這時就需要備份資料庫,再匯入到新的資料庫伺服器上,使用exp imp匯出匯入資料,對於資料量大的來說效率太低,這時候就可以使用expdp impdp提高效率。古太郎 一 expdp匯出流程 在舊資料庫伺服器上操作 1 用system使用者登入資料庫,建立or...

資料庫互導

1 sqlserver與access互導 方法一 用sql語句 匯出到access insert into openrowset microsoft.jet.oledb.4.0 x a.mdb admin a表 select from 資料庫名.b表 匯入access insert into b表 ...

centos postgresql資料庫匯入匯出

匯入整個資料庫 psql u postgres 使用者名稱 資料庫名 預設時同使用者名稱 data dum.sql 匯出整個資料庫 pg dump h localhost u postgres 使用者名稱 資料庫名 預設時同使用者名稱 data dum.sql 匯出某個表 pg dump h loc...