数据导不进oracle数据库,学习笔记:Oracle逻辑导出/导入 数据逻辑导出时跳过指定表不进行导出...

天萃荷净

Oracle数据库逻辑exp导出时,跳过指定某些表,对其表中数据不进行导出

有一个需求,某个用户有很多张表,但是只能使用exp导出,而且想跳过其中某几张表,其他对象包括依赖关系都需要。针对这样的情况,通过分析exp的视图脚本,在exu10tabs视图进行修改,跳过某些表即可

1.修改exu10tabs视图

本测试为11.2.0.4版本,不同版本数据库,可能视图名称和语句有一定出入,请别照搬,exu10tabs在$ORACLE_HOME/rdbms/admin/catexp.sql中

CREATE OR REPLACE VIEW exu10tabs (

objid, dobjid, name, owner, ownerid, tablespace, tsno, fileno,

blockno, audit$, comment$, clusterflag, mtime, modified, tabno,

pctfree$, pctused$, initrans, maxtrans, degree, instances,

cache, tempflags, property, deflog, tsdeflog, roid, recpblk,

secondaryobj, rowcnt, blkcnt, avgrlen, tflags, trigflag,

objstatus, xdbool)

AS /* Heap tables */

SELECT

o$.obj#, o$.dataobj#, o$.name, u$.name, o$.owner#, ts$.name,

t$.ts#, t$.file#, t$.block#, t$.audit$, c$.comment$,

NVL(t$.bobj#, 0), o$.mtime,

DECODE(BITAND(t$.flags, 1), 1, 1, 0), NVL(t$.tab#, 0),

MOD(t$.pctfree$, 100), t$.pctused$, t$.initrans, t$.maxtrans,

NVL(t$.degree, 1), NVL(t$.instances, 1),

DECODE(BITAND(t$.flags, 8), 8, 1, 0),

MOD(TRUNC(o$.flags / 2), 2), t$.property,

DECODE(BITAND(t$.flags, 32), 32, 1, 0), ts$.dflogging, o$.oid$,

t$.spare1, DECODE(BITAND(o$.flags, 16), 16, 1, 0),

NVL(t$.rowcnt, -1), NVL(t$.blkcnt, -1), NVL(t$.avgrln, -1),

t$.flags, t$.trigflag, o$.status,

(SELECT COUNT(*)

FROM sys.opqtype$ opq$

WHERE opq$.obj# = o$.obj# AND

BITAND(opq$.flags, 32) = 32 )

FROM sys.tab$ t$, sys.obj$ o$, sys.ts$ ts$, sys.user$ u$,

sys.com$ c$

WHERE t$.obj# = o$.obj# AND

t$.ts# = ts$.ts# AND

u$.user# = o$.owner# AND

o$.obj# = c$.obj#(+) AND

c$.col#(+) IS NULL AND

BITAND(o$.flags,128) != 128 AND /* Skip recycle bin */

BITAND(t$.property, 64+512) = 0 AND /*skip IOT and ovflw segs*/

BITAND(t$.flags, 536870912) = 0 /* skip IOT mapping table */

and o$.name not in('T_XIFENFEI','T_ORASOS') --增加需要跳过表

UNION ALL /* Index-only tables */

SELECT o$.obj#, o$.dataobj#, o$.name, u$.name, o$.owner#, ts$.name,

i$.ts#, t$.file#, t$.block#, t$.audit$, c$.comment$,

NVL(t$.bobj#, 0), o$.mtime,

DECODE(BITAND(t$.flags, 1), 1, 1, 0),

NVL(t$.tab#, 0), 0, 0, 0, 0,

NVL(t$.degree, 1), NVL(t$.instances, 1),

DECODE(BITAND(t$.flags, 8), 8, 1, 0),

MOD(TRUNC(o$.flags / 2), 2), t$.property,

DECODE(BITAND(t$.flags, 32), 32, 1, 0), ts$.dflogging, o$.oid$,

t$.spare1, DECODE(BITAND(o$.flags, 16), 16, 1, 0),

NVL(t$.rowcnt, -1), NVL(t$.blkcnt, -1), NVL(t$.avgrln, -1),

t$.flags, t$.trigflag, o$.status,

(SELECT COUNT(*)

FROM sys.opqtype$ opq$

WHERE opq$.obj# = o$.obj# AND

BITAND(opq$.flags, 32) = 32 )

FROM sys.tab$ t$, sys.obj$ o$, sys.ts$ ts$, sys.user$ u$,

sys.com$ c$, sys.ind$ i$

WHERE t$.obj# = o$.obj# AND

u$.user# = o$.owner# AND

o$.obj# = c$.obj#(+) AND

c$.col#(+) IS NULL AND

BITAND(o$.flags,128) != 128 AND /* Skip recycle bin */

BITAND(t$.property, 64+512) = 64 AND /* IOT, but not overflow*/

t$.pctused$ = i$.obj# AND/* For IOTs, pctused has index obj# */

i$.ts# = ts$.ts#

2.准备测试条件

创建用户xifenfei,在该用户下面创建四个表,其中有t_xifenfei和t_orasos需要跳过

[oracle@localhost ~]$ ss

SQL*Plus: Release 11.2.0.4.0 Production on Sun Feb 21 21:38:18 2016

Copyright (c) 1982, 2013, Oracle. 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

SQL> create user xifenfei identified by oracle;

User created.

SQL> grant dba to xifenfei;

Grant succeeded.

SQL> conn xifenfei/oracle

Connected.

SQL> create table t_xifenfei as select * from dba_tables;

Table created.

SQL> create table t_xifenfei_exp as select * from dba_tables;

Table created.

SQL> create table t_orasos as select * from dual;

Table created.

SQL> create table xff_t_orasos as select * from dual;

Table created.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

T_ORASOS TABLE

T_XIFENFEI TABLE

T_XIFENFEI_EXP TABLE

XFF_T_ORASOS TABLE

3.exp导出数据测试

[oracle@localhost ~]$ exp xifenfei/oracle owner=xifenfei file=/tmp/www.xifenfei.com.dmp

Export: Release 11.2.0.4.0 - Production on Sun Feb 21 21:40:23 2016

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

Export done in US7ASCII character set and AL16UTF16 NCHAR character set

server uses ZHS16GBK character set (possible charset conversion)

About to export specified users ...

. exporting pre-schema procedural objects and actions

. exporting foreign function library names for user XIFENFEI

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions for user XIFENFEI

About to export XIFENFEI's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export XIFENFEI's tables via Conventional Path ...

. . exporting table T_XIFENFEI_EXP 3374 rows exported

. . exporting table XFF_T_ORASOS 1 rows exported

. exporting synonyms

. exporting views

. exporting stored procedures

. exporting operators

. exporting referential integrity constraints

. exporting triggers

. exporting indextypes

. exporting bitmap, functional and extensible indexes

. exporting posttables actions

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting statistics

Export terminated successfully without warnings.

通过测试,我们发现,在xifenfei用户中有四个表,按照我们的设想跳过了事先配置的表.通过修改exu10tabs脚本,完美实现exp跳部分表

--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之学习笔记:Oracle逻辑导出/导入 数据逻辑导出时跳过指定表不进行导出

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值