ITPub博客

首页 > 数据库 > Oracle > [20200309]expdp 与read only.txt

[20200309]expdp 与read only.txt

原创 Oracle 作者:lfree 时间:2020-03-09 10:28:40 0 删除 编辑

[20200309]expdp 与read only.txt

--//链接:http://www.itpub.net/thread-2128382-1-1.html问的问题。
--//请教各位大佬,在dataguard的read only模式下,不做转换,如何使用expdp导出数据?

--//在本地read only的情况下,不能使用expdp导出数据的。。

1.环境:
SYS@bookdg> select open_mode from v$database ;
OPEN_MODE
--------------------
READ ONLY WITH APPLY

$ expdp scott/book tables=T
Export: Release 11.2.0.4.0 - Production on Mon Mar 9 10:09:15 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-31626: job does not exist
ORA-31633: unable to create master table "SCOTT.SYS_EXPORT_TABLE_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 1038
ORA-16000: database open for read-only access
--//无法建立master table SCOTT.SYS_EXPORT_TABLE_05.

2.可以找一台读写的机器,通过dblink实现到处,甚至导入。

CREATE PUBLIC DATABASE LINK TEST040
 CONNECT TO SCOTT
 IDENTIFIED BY book
 USING 'bookdg';

SYS@book> select sysdate from dual@test040;
SYSDATE
-------------------
2020-03-09 10:14:23

SYS@book> alter system set log_archive_dest_state_2=defer scope=memory;
System altered.

SYS@book> alter system archive log current ;
System altered.

SCOTT@book> insert into t  select * from t where rownum=1;
1 row created.

SCOTT@book> commit ;
Commit complete.

SCOTT@book> select count(*) from t;
COUNT(*)
----------
     85034

$ expdp scott/book NETWORK_LINK=test040  tables=T  DUMPFILE=t.dmp
Export: Release 11.2.0.4.0 - Production on Mon Mar 9 10:21:10 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/a*** NETWORK_LINK=test040 tables=T DUMPFILE=t.dmp
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 10 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."T"                                 8.244 MB   85033 rows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--//我在主库导出,你可以发现我停止日志应用,备库少1条记录。
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
  /u01/app/oracle/admin/book/dpdump/t.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Mon Mar 9 10:21:16 2020 elapsed 0 00:00:05
--//OK,导出成功。

3.你还可以直接导入:

$ impdp scott/book NETWORK_LINK=test040  tables=T  REMAP_TABLE=scott.T:scott.T1
Import: Release 11.2.0.4.0 - Production on Mon Mar 9 10:24:12 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/a* NETWORK_LINK=test040 tables=T REMAP_TABLE=scott.T:scott.T1
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 10 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . imported "SCOTT"."SCOTT.T1"                           85033 rows
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at Mon Mar 9 10:24:18 2020 elapsed 0 00:00:06
--//昏,语法有问题,不过还是导入成功了。不需要在后面schema。

SYS@book> select count(*) from scott."SCOTT.T1";
  COUNT(*)
----------
     85033

SYS@book> select count(*) from SCOTT.T;
  COUNT(*)
----------
     85034

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2679129/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7970751