视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
Oracle从Dump文件里提取DDL语句方法说明
2020-11-09 11:54:30 责编:小采
文档


Oracle 从Dump 文件里提取 DDL 语句 方法说明

有关Dump 文件的命令有exp/imp 和 expdp/impdp。 这四个命令之前都有整理过相关的文章。

Oracle EXP/IMP 说明

exp/imp 与 expdp/impdp 对比 及使用中的一些优化事项

Oracle expdp/impdp 使用示例

Oracle 10g Data Pump Expdp/Impdp 详解

Oracle expdp/impdp 从高版本 到 低版本 示例

对于Dump 文件,,我们不能直接提取出Data数据,但是我们可以通过相关的参数,从Dump文件中提取出对应的DDL 语句。

(1)如果是导出导入(exp/imp),那么是indexfile参数。

(2)如果是数据泵(expdp/impdp),那么是sqlfile 参数。

准备工作:

SYS@anqing1(rac1)> create user dvdidentified by dvd;

User created.

SYS@anqing1(rac1)> grant dba to dvd;

Grant succeeded.

SYS@anqing1(rac1)> conn dvd/dvd;

Connected.

DVD@anqing1(rac1)> create table t1(idnumber);

Table created.

DVD@anqing1(rac1)> insert into t1values(1);

1 row created.

DVD@anqing1(rac1)> commit;

Commit complete.

DVD@anqing1(rac1)> create index idx_t1on t1(id);

Index created.

DVD@anqing1(rac1)>

一.使用导出导入命令 1.1 导出dvd 用户的数据,生成dump文件

[oracle@rac1 ~]$ exp dvd/dvd file=dvd.dmpowner=dvd

Export: Release 10.2.0.4.0 - Production onWed Sep 21 19:50:14 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 10gEnterprise Edition Release 10.2.0.4.0 - Production

With the Partitioning, Real ApplicationClusters, OLAP, Data Mining

and Real Application Testing options

Export done in US7ASCII character set andAL16UTF16 NCHAR character set

server uses ZHS16GBK character set(possible charset conversion)

About to export specified users ...

. exporting pre-schema procedural objectsand actions

. exporting foreign function library namesfor user DVD

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions foruser DVD

About to export DVD's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export DVD's tables via ConventionalPath ...

. . exporting table T1 1 rows exported

EXP-00091: Exporting questionablestatistics.

. exporting synonyms

. exporting views

. exporting stored procedures

. exporting operators

. exporting referential integrityconstraints

. exporting triggers

. exporting indextypes

. exporting bitmap, functional andextensible indexes

. exporting posttables actions

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objectsand actions

. exporting statistics

Export terminated successfully withwarnings.

1.2 从dump 文件里提取DDL语句

[oracle@rac1 ~]$ imp dvd/dvd file=dvd.dmpfromuser=dvd touser=dvd indexfile=dvd.sql

Import: Release 10.2.0.4.0 - Production onWed Sep 21 19:50:50 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 10gEnterprise Edition Release 10.2.0.4.0 - Production

With the Partitioning, Real ApplicationClusters, OLAP, Data Mining

and Real Application Testing options

Export file created by EXPORT:V10.02.01 viaconventional path

import done in US7ASCII character set andAL16UTF16 NCHAR character set

import server uses ZHS16GBK character set (possiblecharset conversion)

. . skipping table "T1"

Import terminated successfully withoutwarnings.

这里要注意2点:

(1) 该import 命令并没有真正的import data,而只是生成了我们对应用户下所有DDL的sql 语句。

(2) 对于表的DDL语句,用REM 进行了注释。

[oracle@rac1 ~]$ cat dvd.sql

REM CREATE TABLE "DVD"."T1" ("ID" NUMBER)PCTFREE 10 PCTUSED 40 INITRANS

REM 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1

REM BUFFER_POOL DEFAULT) TABLESPACE "USERS" LOGGING NOCOMPRESS ;

REM ... 1 rows

CONNECT DVD;

CREATE INDEX "DVD"."IDX_T1"ON "T1" ("ID" ) PCTFREE 10 INITRANS 2 MAXTRANS

255 STORAGE(INITIAL 65536 FREELISTS 1FREELIST GROUPS 1 BUFFER_POOL

DEFAULT) TABLESPACE "USERS"LOGGING ;

如果只想看索引的DDL,那么可以用grep命令,讲REM 的不显示。

Linux Grep 命令说明

[oracle@rac1 ~]$ cat dvd.sql|grep -v REM

CONNECT DVD;

CREATE INDEX"DVD"."IDX_T1" ON "T1" ("ID" ) PCTFREE10 INITRANS 2 MAXTRANS

255 STORAGE(INITIAL 65536 FREELISTS 1FREELIST GROUPS 1 BUFFER_POOL

DEFAULT) TABLESPACE "USERS"LOGGING ;

下载本文
显示全文
专题