天天看點

oracle 泵式導出,Oracle Expdp Impdp 資料泵導入導出

2019獨角獸企業重金招聘Python工程師标準>>>

oracle 泵式導出,Oracle Expdp Impdp 資料泵導入導出

導出

sql>conn username/[email protected] as sysdba;

sql>create directory dmp_dir as 'd:\temp';

sql>select * from dba_directories;

sql>grant read,write on directory dmp_dir to username;

sql>grant exp_full_database to username;

sql>grant imp_full_database to username;

sql>alter user username quota unlimited on user_tablespace ;

c:\expdp username/[email protected]/orcl DIRECTORY=dmp_dir SCHEMAS=schema_name(username) dumpfile=XXX.dmp logfile=XXX.log

-- content=metadata_only : 表結構

-- include=TABLE,VIEW,Procedure,sequence (表、視圖、存儲過程、序列)

c:\expdp username/[email protected]/orcl DIRECTORY=dmp_dir SCHEMAS=schema_name(username) dumpfile=XXX.dmp logfile=XXX.log CONTENT=METADATA_ONLY INCLUDE=TABLE,VIEW,Procedure,sequence

建立邏輯目錄,Oracle不會自動建立實際的實體目錄“D:\temp”(務必先手動建立此目錄然後再執行oracle 導出目錄定義),僅僅是進行定義邏輯路徑dmp_dir;

sql>conn username/[email protected] as sysdba;

sql>create directory dmp_dir as 'd:\temp';

sql>select * from dba_directories;

oracle 定義路徑前必須建立實體位址,不然會出現如下錯誤。

ORA-39002: invalid operation

ORA-39070: Unable to open the log file.

ORA-29283: invalid file operation

ORA-06512: at "SYS.UTL_FILE", line 536

ORA-29283: invalid file operation

确認目錄存在,當出現如下錯誤,看看是否有授權

ORA-39002: invalid operation

ORA-39070: Unable to open the log file.

ORA-39087: directory name DUMP_DIR is invalid

解決方法:

grant read,write on directory dump_dir to username;

導出時出現如下錯誤,表示沒有給使用者授權(grant exp_full_database to username;)

ORA-31631: privileges are required

ORA-39161: Full database jobs require privileges

導入時出現如下錯誤,表示沒有給使用者授權(grant imp_full_database to username;)

ORA-31631: privileges are required

ORA-39122: Unprivileged users may not perform REMAP_SCHEMA remappings.

表空間已滿提示錯誤:

ORA-31626: job does not exist

ORA-31633: unable to create master table "DRM_PFM.SYS_EXPORT_FULL_06"

ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95

ORA-06512: at "SYS.KUPV$FT", line 1020

ORA-01658: unable to create INITIAL extent for segment in tablespace TS_PFM

檢視表空間情況:

SELECT a.tablespace_name "表空間名",

total / 1024 / 1024 "表空間大小機關[M]",

free / 1024 / 1024 "表空間剩餘大小機關[M]",

(total - free) / 1024 / 1024 "表空間使用大小機關[M]",

Round((total - free) / total, 4) * 100 "使用率 [%]"

FROM (SELECT tablespace_name, Sum(bytes) free

FROM DBA_FREE_SPACE

GROUP BY tablespace_name) a,

(SELECT tablespace_name, Sum(bytes) total

FROM DBA_DATA_FILES

GROUP BY tablespace_name) b

WHERE a.tablespace_name = b.tablespace_name;

解決方法:

-- 增加表空間容量

ALTER DATABASE DATAFILE 'D:\DEVELOP\DATABASE\TABLESPACE\TS_PFM.DBF' RESIZE 200M;

-- 修改表空間自動擴充

ALTER DATABASE DATAFILE 'D:\DEVELOP\DATABASE\TABLESPACE\TS_PFM.DBF' AUTOEXTEND ON NEXT 100M MAXSIZE 1G;

如果表空間設定了自動擴充,查詢到的表空間容量快滿了,手動執行表空間容量增加;我的就是設定了表空間自動擴充的,但是expdp 導出的時候還是報錯,通過手動增加容量解決問題。

檔案已存在提示錯誤,删除之前因為出現錯誤建立的檔案重新執行即可。

ORA-39001: invalid argument value

ORA-39000: bad dump file specification

ORA-31641: unable to create dump file "d:\temp\oracle\drm_pfm0711.dmp"

ORA-27038: created file already exists

OSD-04010: option specified, file already exists

根據使用者導出資料提示

ORA-31626: job does not exist

ORA-31633: unable to create master table "DRM_PFM.SYS_EXPORT_SCHEMA_05"

ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95

ORA-06512: at "SYS.KUPV$FT", line 1020

ORA-01950: no privileges on tablespace 'TS_PFM'

解決辦法

SQL> alter user username quota unlimited on tablespace_name ;

導入

角色确實不存在忽略即可,如果還是導入不了看看是否是表空間不足。

IMP-00058: ORACLE error 1653 encountered

ORA-01653: unable to extend table user.testTable by 8 in tablespace TS_test

IMP-00028: partial import of previous table rolled back: 10 rows rolled back

IMP-00017: following statement failed with ORACLE error 1917:

"GRANT SELECT ON "testTable" TO "testUser""

IMP-00003: ORACLE error 1917 encountered

ORA-01917: user or role 'testUser' does not exist

ORA-39006: internal error

ORA-39213: Metadata processing is notavailable

SQL> execute sys.dbms_metadata_util.load_stylesheets;