[20130727]ORACLE 12C使用expdp匯出view資料.txt
[20130727]ORACLE 12C使用expdp匯出view資料.txt
12C新特性裡面可以定義試圖,然後透過view當作表一樣匯出資料,然後匯入資料庫,自己做一個測試:
1.建立測試環境:
SQL> create view v_emp_dept as select emp.*,dept.dname from dept,emp where dept.deptno=emp.deptno;
--system使用者執行
CREATE OR REPLACE DIRECTORY tmp_expdp AS 'D:\tmp\expdp\';
SQL> GRANT READ, WRITE ON DIRECTORY tmp_expdp TO scott;
Grant succeeded.
SQL> grant EXP_FULL_DATABASE to scott;
Grant succeeded.
SQL> grant IMP_FULL_DATABASE to scott;
Grant succeeded.
2.expdp匯出檢視資訊以及資料:
d:\tmp>expdp scott/tiger@test01p views_as_tables=v_emp_dept directory=tmp_expdp dumpfile=emp_dept.dmp
Export: Release 12.1.0.1.0 - Production on Sun Jul 28 21:50:26 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/********@test01p views_as_tables=v_emp_dept directory=tmp_expdp dumpfile=emp_dept.dmp */
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
Total estimation using BLOCKS method: 16 KB
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
. . exported "SCOTT"."V_EMP_DEPT" 9.296 KB 14 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
D:\TMP\EXPDP\EMP_DEPT.DMP
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Sun Jul 28 21:50:41 2013 elapsed 0 00:00:13
3.impdp匯入:
d:\tmp>impdp scott/tiger@test01p directory=tmp_expdp dumpfile=emp_dept.dmp
Import: Release 12.1.0.1.0 - Production on Sun Jul 28 21:54:57 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01": scott/********@test01p directory=tmp_expdp dumpfile=emp_dept.dmp */
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
ORA-39325: TABLE_EXISTS_ACTION cannot be applied to "SCOTT"."V_EMP_DEPT".
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
Job "SCOTT"."SYS_IMPORT_FULL_01" completed with 1 error(s) at Sun Jul 28 21:55:07 2013 elapsed 0 00:00:07
--檢視存在,無法匯入,改名檢視,或者使用remap_table引數。選擇修改檢視看看。
SQL> rename V_EMP_DEPT to V_EMP_DEPT1;
Table renamed.
d:\tmp>impdp scott/tiger@test01p directory=tmp_expdp dumpfile=emp_dept.dmp
Import: Release 12.1.0.1.0 - Production on Sun Jul 28 22:00:19 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01": scott/********@test01p directory=tmp_expdp dumpfile=emp_dept.dmp */
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
. . imported "SCOTT"."V_EMP_DEPT" 9.296 KB 14 rows
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at Sun Jul 28 22:00:24 2013 elapsed 0 00:00:03
--可以發現匯入後,建立了新表v_emp_dept.
12C新特性裡面可以定義試圖,然後透過view當作表一樣匯出資料,然後匯入資料庫,自己做一個測試:
1.建立測試環境:
SQL> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
SQL> create view v_emp_dept as select emp.*,dept.dname from dept,emp where dept.deptno=emp.deptno;
--system使用者執行
CREATE OR REPLACE DIRECTORY tmp_expdp AS 'D:\tmp\expdp\';
SQL> GRANT READ, WRITE ON DIRECTORY tmp_expdp TO scott;
Grant succeeded.
SQL> grant EXP_FULL_DATABASE to scott;
Grant succeeded.
SQL> grant IMP_FULL_DATABASE to scott;
Grant succeeded.
2.expdp匯出檢視資訊以及資料:
d:\tmp>expdp scott/tiger@test01p views_as_tables=v_emp_dept directory=tmp_expdp dumpfile=emp_dept.dmp
Export: Release 12.1.0.1.0 - Production on Sun Jul 28 21:50:26 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/********@test01p views_as_tables=v_emp_dept directory=tmp_expdp dumpfile=emp_dept.dmp */
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
Total estimation using BLOCKS method: 16 KB
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
. . exported "SCOTT"."V_EMP_DEPT" 9.296 KB 14 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
D:\TMP\EXPDP\EMP_DEPT.DMP
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Sun Jul 28 21:50:41 2013 elapsed 0 00:00:13
3.impdp匯入:
d:\tmp>impdp scott/tiger@test01p directory=tmp_expdp dumpfile=emp_dept.dmp
Import: Release 12.1.0.1.0 - Production on Sun Jul 28 21:54:57 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01": scott/********@test01p directory=tmp_expdp dumpfile=emp_dept.dmp */
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
ORA-39325: TABLE_EXISTS_ACTION cannot be applied to "SCOTT"."V_EMP_DEPT".
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
Job "SCOTT"."SYS_IMPORT_FULL_01" completed with 1 error(s) at Sun Jul 28 21:55:07 2013 elapsed 0 00:00:07
--檢視存在,無法匯入,改名檢視,或者使用remap_table引數。選擇修改檢視看看。
SQL> rename V_EMP_DEPT to V_EMP_DEPT1;
Table renamed.
d:\tmp>impdp scott/tiger@test01p directory=tmp_expdp dumpfile=emp_dept.dmp
Import: Release 12.1.0.1.0 - Production on Sun Jul 28 22:00:19 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01": scott/********@test01p directory=tmp_expdp dumpfile=emp_dept.dmp */
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
. . imported "SCOTT"."V_EMP_DEPT" 9.296 KB 14 rows
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at Sun Jul 28 22:00:24 2013 elapsed 0 00:00:03
SQL> column object_name format a20
SQL> select object_id,data_object_id,object_name,object_type from dba_objects where wner=user and object_name in ('V_EMP_DEPT','V_EMP_DEPT1');
OBJECT_ID DATA_OBJECT_ID OBJECT_NAME OBJECT_TYPE
---------- -------------- -------------------- -----------------------
92488 V_EMP_DEPT1 VIEW
92776 92776 V_EMP_DEPT TABLE
--可以發現匯入後,建立了新表v_emp_dept.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-767376/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- Oracle 12c expdp和impdp匯出匯入表Oracle
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- expdp impdp只匯出匯入viewView
- expdp 使用QUERY 匯出部分資料。
- Oracle expdp資料泵遠端匯出Oracle
- 使用資料泵工具expdp工具匯出資料
- oracle按照表條件expdp匯出資料Oracle
- Oracle10g 資料泵匯出命令 expdp 使用總結Oracle
- expdp中使用include或者exclude匯出資料
- expdp遠端匯出資料
- Oracle expdp/impdp匯出匯入命令及資料庫備份Oracle資料庫
- Oracle expdp/impdp匯入匯出備份資料庫指令碼Oracle資料庫指令碼
- Oracle expdp匯出多表或表中的部分資料Oracle
- expdp匯出表的部分資料
- oracle匯入匯出之expdp/impdpOracle
- 使用EXPDP/IMPDP匯入匯出表中資料/後設資料測試
- 資料庫泵(expdp/impdp)匯入匯出流程資料庫
- oracle資料庫使用sqlldr命令匯入txt資料Oracle資料庫SQL
- ORACLE expdp匯出遠端庫指定使用者資料到本地資料庫Oracle資料庫
- 【EXPDP/IMPDP】使用 EXPDP/IMPDP工具“模糊”匯出和匯入
- expdp impdp 資料庫匯入匯出命令詳解資料庫
- Oracle使用資料泵匯出匯入表Oracle
- 在鎖表情況下expdp匯出資料
- 資料泵 EXPDP 匯出工具的使用
- 12c 資料泵匯入匯出級別
- Oracle 匯出txt檔案Oracle
- Oracle 資料匯入匯出Oracle
- Oracle資料匯入匯出Oracle
- 通過EXPDP/IMPDP匯出匯入遠端資料倒本地
- 使用Exp和Expdp匯出資料的效能對比與優化優化
- 使用expdp匯出分割槽表中的部分分割槽資料
- Oracle使用sqluldr2匯出資料OracleSQL
- oracle10g expdp資料泵的bug,按schema匯出,匯入impdp時無jobOracle
- 使用Exp和Expdp匯出資料的效能對比與最佳化
- 【資料泵】EXPDP匯出表結構(真實案例)
- Oracle表中資料匯出成 Txt格式的方案Oracle
- expdp 匯出指令碼指令碼