今天给导出一个dmp然后导入到另一个库中,一切都很正常,没有导出警告也没有导入警告,正打算OK的时候,想想还是检查一下两个库中的对象个数是否相同,一检查发现有几张表没有被导入,赶紧查看的导出log,确实没有导出,但是没有任何警告和错误啊。于是把导入导出有重新走了一遍,问题依旧。下来时一顿的google,发现问题可能出在11g的新特性上:deferred_segment_creation。官方的解释如下:
Use this clause to determine when the database should create the segment(s) for this table:
* SEGMENT CREATION DEFERRED:
This clause defers creation of the table segment — as well as segments for any LOB columns of the table,
any indexes created implicitly as part of table creation, and any indexes subsequently explicitly created
on the table — until the first row of data is inserted into the table. At that time, the segments for
the table, LOB columns and indexes, and explicitly created indexes are all materialized and inherit any
storage properties specified in this CREATE TABLE statement or, in the case of explicitly created indexes,
the CREATE INDEX statement. These segments are created regardless whether the initial insert operation is
uncommitted or rolled back. This is the default value.
* SEGMENT CREATION IMMEDIATE:
The table segment is created as part of this CREATE TABLE statement.Immediate segment creation
is useful, for example, if your application depends upon the object appearing in the DBA_, USER_,
and ALL_SEGMENTS data dictionary views, because the object will not appear in those views until the
segment is created. This clause overrides the setting of the DEFERRED_SEGMENT_CREATION initialization
parameter.
原因可能是还没有任何任何段的表在一些系统视图中缺少相关信息,导致exp程序没有将他们作为导出对象,以至于没有导出这些表。于是实验了一下,果然如此,问题顺利解决,实验过程如下:
0.数据库版本
test@LEISORE> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
1. 创建用户:
sys@LEISORE>create user test identified by test;
sys@LEISORE>GRANT CONNECT TO test;
sys@LEISORE>GRANT RESOURCE TO test;
sys@LEISORE>GRANT SELECT_CATALOG_ROLE TO test;
sys@LEISORE>GRANT EXECUTE_CATALOG_ROLE TO test;
sys@LEISORE>GRANT RECOVERY_CATALOG_OWNER TO test;
sys@LEISORE>GRANT SELECT ANY DICTIONARY TO test;
2. 创建测试表
test@LEISORE> create table test(col number(10));
test@LEISORE> select table_name,segment_created from user_tables;
TABLE_NAME SEG
------------------------------ ---
TEST NO
注意:没有创建segment
3. 导出
C:/>exp test/test@DB_106 file=test.dmp log=log.log
Export: Release 11.2.0.1.0 - Production on 星期六 2月 12 16:09:26 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
. 正在导出 pre-schema 过程对象和操作
. 正在导出用户 TEST 的外部函数库名
. 导出 PUBLIC 类型同义词
. 正在导出专用类型同义词
. 正在导出用户 TEST 的对象类型定义
即将导出 TEST 的对象...
. 正在导出数据库链接
. 正在导出序号
. 正在导出簇定义
. 即将导出 TEST 的表通过常规路径...
注意:没有导出任何表
. 正在导出同义词
. 正在导出视图
. 正在导出存储过程
. 正在导出运算符
. 正在导出引用完整性约束条件
. 正在导出触发器
. 正在导出索引类型
. 正在导出位图, 功能性索引和可扩展索引
. 正在导出后期表活动
. 正在导出实体化视图
. 正在导出快照日志
. 正在导出作业队列
. 正在导出刷新组和子组
. 正在导出维
. 正在导出 post-schema 过程对象和操作
. 正在导出统计信息
成功终止导出, 没有出现警告。
4. 导入
test@LEISORE> drop table test;
test@LEISORE> select count(*) from user_objects where object_type='TABLE';
COUNT(*)
----------
0
C:/>imp test/test@DB_106 file=test.dmp fromuser=test touser=test
Import: Release 11.2.0.1.0 - Production on 星期六 2月 12 16:14:12 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
经由常规路径由 EXPORT:V11.02.00 创建的导出文件
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
成功终止导入, 没有出现警告。
5. 查看导入结果
test@LEISORE> select table_name,segment_created from user_tables;
未选定行
问题:没有导入表test
6. 解决
6.1插入一行然后删除然后导出导入
6.1.1 插入
test@LEISORE> insert into test values(1);
已创建 1 行。
test@LEISORE> commit;
提交完成。
test@LEISORE> delete from test;
已删除 1 行。
test@LEISORE> commit;
提交完成。
6.1.2 导出
C:/>exp test/test@DB_106 file=test.dmp log=log.log
Export: Release 11.2.0.1.0 - Production on 星期六 2月 12 16:35:40 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
. 正在导出 pre-schema 过程对象和操作
. 正在导出用户 TEST 的外部函数库名
. 导出 PUBLIC 类型同义词
. 正在导出专用类型同义词
. 正在导出用户 TEST 的对象类型定义
即将导出 TEST 的对象...
. 正在导出数据库链接
. 正在导出序号
. 正在导出簇定义
. 即将导出 TEST 的表通过常规路径...
. . 正在导出表 TEST导出了 1 行
. 正在导出同义词
. 正在导出视图
. 正在导出存储过程
. 正在导出运算符
. 正在导出引用完整性约束条件
. 正在导出触发器
. 正在导出索引类型
. 正在导出位图, 功能性索引和可扩展索引
. 正在导出后期表活动
. 正在导出实体化视图
. 正在导出快照日志
. 正在导出作业队列
. 正在导出刷新组和子组
. 正在导出维
. 正在导出 post-schema 过程对象和操作
. 正在导出统计信息
成功终止导出, 没有出现警告。
6.1.3 删除表
test@LEISORE> drop table test;
表已删除。
test@LEISORE> select table_name,segment_created from user_tables;
未选定行
6.1.4 导入
C:/>imp test/test@DB_106 file=test.dmp fromuser=test touser=test
Import: Release 11.2.0.1.0 - Production on 星期六 2月 12 16:37:44 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
经由常规路径由 EXPORT:V11.02.00 创建的导出文件
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. . 正在导入表 "TEST"导入了 1 行
成功终止导入, 没有出现警告。
6.1.5 导入结果
test@LEISORE> select table_name,segment_created from user_tables;
TABLE_NAME SEG
------------------------------ ---
TEST YES
6.2 使用SEGMENT CREATION IMMEDIATE建表
6.2.1 建表
test@LEISORE> create table test(col number(10)) SEGMENT CREATION IMMEDIATE;
表已创建。
test@LEISORE> select table_name,segment_created from user_tables;
TABLE_NAME SEG
------------------------------ ---
TEST YES
6.2.2 导出
C:/>exp test/test@DB_106 file=test.dmp log=log.log
Export: Release 11.2.0.1.0 - Production on 星期六 2月 12 16:44:52 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
. 正在导出 pre-schema 过程对象和操作
. 正在导出用户 TEST 的外部函数库名
. 导出 PUBLIC 类型同义词
. 正在导出专用类型同义词
. 正在导出用户 TEST 的对象类型定义
即将导出 TEST 的对象...
. 正在导出数据库链接
. 正在导出序号
. 正在导出簇定义
. 即将导出 TEST 的表通过常规路径...
. . 正在导出表 TEST导出了 0 行
. 正在导出同义词
. 正在导出视图
. 正在导出存储过程
. 正在导出运算符
. 正在导出引用完整性约束条件
. 正在导出触发器
. 正在导出索引类型
. 正在导出位图, 功能性索引和可扩展索引
. 正在导出后期表活动
. 正在导出实体化视图
. 正在导出快照日志
. 正在导出作业队列
. 正在导出刷新组和子组
. 正在导出维
. 正在导出 post-schema 过程对象和操作
. 正在导出统计信息
成功终止导出, 没有出现警告。
6.2.3 删除表
test@LEISORE> drop table test;
表已删除。
test@LEISORE> select table_name,segment_created from user_tables;
未选定行
6.2.4 导入
CC:/>imp test/test@DB_106 file=test.dmp fromuser=test touser=test
Import: Release 11.2.0.1.0 - Production on 星期六 2月 12 16:45:45 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
经由常规路径由 EXPORT:V11.02.00 创建的导出文件
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. . 正在导入表 "TEST"导入了 0 行
成功终止导入, 没有出现警告。
6.2.5 导入结果
test@LEISORE> select table_name,segment_created from user_tables;
TABLE_NAME SEG
------------------------------ ---
TEST NO