今天一个同事很肯定的告诉我,当imp对象时,如果导出的原始表空间不存在的话会报错,我奇怪,我觉得会导入用户的default tablespace,如果default tablespace没有指定的话,那么9i会导入system tablespace, 10g会导入users tablespace.
亲手做了一个试验,证明我的理解没有错:
导出数据库sid:testdb
create user leiz
identified by leiz
default tablespace leiz
grant connect, resource to leiz
CREATE TABLESPACE "leiz"
LOGGING
DATAFILE 'D:\ORACLE\ORADATA\NCPCDB\leiz.ora' SIZE 5M EXTENT
MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
导入数据库sid:ncpcdb
create user coolyl
identified by coolyl
default tablespace coolyl
grant connect, resource to coolyl
CREATE TABLESPACE "coolyl"
LOGGING
DATAFILE 'D:\ORACLE\ORADATA\NCPCDB\coolyl.ora' SIZE 5M EXTENT
MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
1. 导出导入用户的默认表空间不一致
C:\Documents and Settings\zhanglei>exp leiz/leiz@testdb file=c:\leiz.dmp tables=test1
Export: Release 9.2.0.1.0 - Production on 星期五 3月 13 16:43:45 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
连接到: Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径 ...
. . 正在导出表 TEST1 23145 行被导出
在没有警告的情况下成功终止导出。
C:\Documents and Settings\zhanglei>imp coolyl/coolyl@ncpcdb fromuser=leiz touser=coolyl file=c:\leiz.dmp
Import: Release 9.2.0.1.0 - Production on 星期五 3月 13 16:44:30 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
连接到: Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
经由常规路径导出由EXPORT:V09.02.00创建的文件
警告: 此对象由 LEIZ 导出, 而不是当前用户
已经完成ZHS16GBK字符集和AL16UTF16 NCHAR 字符集中的导入
. . 正在导入表 "TEST1" 23145行被导入
成功终止导入,但出现警告。
select b.table_name, b.tablespace_name from user_tables b
TEST1 LEIZ
select b.table_name, b.tablespace_name from user_tables b
TEST1 COOLYL
结果:成功导入,导入到用户的默认表空间下了,与有无原始表空间无关。
2. 导入用户未指定表空间
9i -> 9i
C:\Documents and Settings\zhanglei>imp coolyl/coolyl@ncpcdb fromuser=leiz touser=coolyl file=c:\leiz.dmp
Import: Release 9.2.0.1.0 - Production on 星期五 3月 13 16:44:30 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
连接到: Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
经由常规路径导出由EXPORT:V09.02.00创建的文件
警告: 此对象由 LEIZ 导出, 而不是当前用户
已经完成ZHS16GBK字符集和AL16UTF16 NCHAR 字符集中的导入
. . 正在导入表 "TEST1" 23145行被导入
成功终止导入,但出现警告。
select b.table_name, b.tablespace_name from user_tables b
TEST1 SYSTEM
9i -> 10g
C:\Documents and Settings\zhanglei>imp coolyl/coolyl@nfdb fromuser=leiz touser=coolyl file=c:\leiz.dmp
Import: Release 9.2.0.1.0 - Production on 星期五 3月 13 16:53:09 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Produc
tionWith the Partitioning, OLAP and Data Mining options
经由常规路径导出由EXPORT:V09.02.00创建的文件
警告: 此对象由 LEIZ 导出, 而不是当前用户
已经完成ZHS16GBK字符集和AL16UTF16 NCHAR 字符集中的导入
. . 正在导入表 "TEST1" 23145行被导入
成功终止导入,但出现警告。
select b.table_name, b.tablespace_name from user_tables b
TEST1 USERS
结果:如果未指定用户的默认表空间,9i自动导入到system表空间,10g自动导入到users表空间
总结论:实践是检验真理的唯一标准
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9252210/viewspace-567223/ ,如需转载,请注明出处,否则将追究法律责任。