您的位置:首页 > 数据库 > Oracle

oracle中imp导入参数show=y 详解

2013-11-20 20:02 471 查看
在imp的帮助中: SHOW     just list file contents (N),默认为N。

下面通过实验说明2点:

1.show=y 可以显示dmp文件中创建对象的语句。

2.show=y 就如同oracle说的那样, just list file contents,这里不进行导入操作。

准备实验环境:

1.创建用户,并赋权:

SQL> create user testshow identified by a123;

User created

SQL> grant connect,resource to testshow;

Grant succeeded

SQL> grant create synonym to testshow 

  2  / 

Grant succeeded

2.创建对象:

SQL> create table test (id number,name varchar2(20));

Table created

SQL> create synonym emp for scott.emp;

Synonym created

3.查看对象是否创建成功:

SQL> select count(*) from emp; 

  COUNT(*) 

---------- 

        16 

SQL> select * from test; 

        ID NAME 

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

开始实验:

1.导出testshow用户的所有对象

C:\Users\yafeishi>exp system/dang file=testshow.dmp  compress=n owner=testshow 

Export: Release 10.2.0.3.0 - Production on 星期一 8月 27 13:20:00 2012 

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production 

With the Partitioning, OLAP and Data Mining options 

已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集 

即将导出指定的用户... 

. 正在导出 pre-schema 过程对象和操作 

. 正在导出用户 TESTSHOW 的外部函数库名 

. 导出 PUBLIC 类型同义词 

. 正在导出专用类型同义词 

. 正在导出用户 TESTSHOW 的对象类型定义 

即将导出 TESTSHOW 的对象... 

. 正在导出数据库链接 

. 正在导出序号 

. 正在导出簇定义 

. 即将导出 TESTSHOW 的表通过常规路径... 

. . 正在导出表                            TEST导出了           0 行 

. 正在导出同义词 

. 正在导出视图 

. 正在导出存储过程 

. 正在导出运算符 

. 正在导出引用完整性约束条件 

. 正在导出触发器 

. 正在导出索引类型 

. 正在导出位图, 功能性索引和可扩展索引 

. 正在导出后期表活动 

. 正在导出实体化视图 

. 正在导出快照日志 

. 正在导出作业队列 

. 正在导出刷新组和子组 

. 正在导出维 

. 正在导出 post-schema 过程对象和操作 

. 正在导出统计信息 

成功终止导出, 没有出现警告。

2.删除testshow下的test表和emp同名:

SQL> drop table test;

Table dropped

SQL> select * from test;

select * from test

ORA-00942: 表或视图不存在

SQL> drop synonym emp;

Synonym dropped

SQL> select count(*) from emp;

select count(*) from emp

ORA-00942: 表或视图不存在

3.show=y 进行[b]导入操作[/b]

C:\Users\yafeishi>imp system/dang file=testshow.dmp log=testshow.log show=y from 

user=testshow touser=testshow 

Import: Release 10.2.0.3.0 - Production on 星期一 8月 27 13:20:45 2012 

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production 

With the Partitioning, OLAP and Data Mining options 

经由常规路径由 EXPORT:V10.02.01 创建的导出文件 

已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入 

. 正在将 TESTSHOW 的对象导入到 TESTSHOW 

"BEGIN  " 

"sys.dbms_logrep_imp.instantiate_schema(schema_name=>SYS_CONTEXT('USERENV','" 

"CURRENT_SCHEMA'), export_db_name=>'ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM', i" 

"nst_scn=>'11274324817182');" 

"COMMIT; END;" 

"ALTER SESSION SET CURRENT_SCHEMA= "TESTSHOW"" 

"CREATE TABLE "TEST" ("ID" NUMBER, "NAME" VARCHAR2(20))  PCTFREE 10 PCTUSED " 

"40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUP" 

"S 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS" LOGGING NOCOMPRESS" 

. . 正在跳过表 "TEST" 

"ALTER SESSION SET CURRENT_SCHEMA= "TESTSHOW"" 

"CREATE SYNONYM "EMP" FOR "SCOTT"."EMP"" 

成功终止导入, 没有出现警告。 

可以看到日志打出了创建对象的语句,证明了第一点。

再查看库中对象是否导入

SQL> select * from test;

select * from test

ORA-00942: 表或视图不存在

SQL> select count(*) from emp;

select count(*) from emp

ORA-00942: 表或视图不存在

看到对象并没有[b]导入,证明了第二点。[/b]

4.show=n [b]导入[/b]

C:\Users\yafeishi>imp system/dang file=testshow.dmp log=testshow.log show=n igno 

re=y fromuser=testshow touser=testshow 

Import: Release 10.2.0.3.0 - Production on 星期一 8月 27 13:21:35 2012 

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

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production 

With the Partitioning, OLAP and Data Mining options 

经由常规路径由 EXPORT:V10.02.01 创建的导出文件 

已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入 

. 正在将 TESTSHOW 的对象导入到 TESTSHOW 

. . 正在导入表                          "TEST"导入了           0 行 

成功终止导入, 没有出现警告。

SQL> select * from test;

        ID NAME

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

SQL> select count(*) from emp;

  COUNT(*)

----------

        16

对象也导入进来了。

---EOF

原文地址:http://blog.yafeishi.net/2012/08/oracle-imp-show-y.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: