2011-06-23 52 views
1

我知道如何使用“imp”导入.dmp数据。但是,我想知道是否必须先创建表空间,例如?在oracle中导入数据

其他人有一个oracle数据库实例,并且他创建了一个defaule表空间为“tabspace_one”的用户“sa_one”,然后他在该表空间下创建了一些表。

然后他将用户“sa_one”下的对象导出到xx.dmp。

现在,在我的机器中,我有自己的数据库实例,并创建一个用户“sa_two”,其defaule表空间为“tabspace_two”。

现在,如果我想将xx.dmp导入到用户“sa_two”。我使用cmd:

imp fromuser=sa_one touser=sa_two file=xx.dmp 

但我不知道是否必须在我的数据库instace中创建一个表空间“tabspace_one”?

回答

1

hguser,

如果你这样做,你说的话:

imp fromuser=sa_one touser=sa_two file=xx.dmp 

随后的数据将被导入到表空间中的“sa_two”的架构已设置为默认表空间。尽管我必须承认 - 我无法找到Oracle文档明确表示,这是真的,但我没有找到这个预言维基: http://wiki.oracle.com/thread/1284972/EXP+%26+IMP+only+restores+to+same+tablespace(s)

或者,你可以只使用EXPDP IMPDP和及发行REMAP_TABLESPACE为进口。

一切,这是当你尝试导入到不存在的表空间会发生什么:

C:\Users\jslowik\Desktop>impdp user/[email protected]_name dumpfile=datfile.dat full=y 

Import: Release 11.2.0.1.0 - Production on Thu Jun 23 15:34:27 2011 

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 
ORA-31626: job does not exist 
ORA-31633: unable to create master table "SC_BASE.SYS_IMPORT_FULL_05" 
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95 
ORA-06512: at "SYS.KUPV$FT", line 1020 
ORA-00959: tablespace 'TABLES' does not exist 
1

是的,我相信你必须创建表空间并赋予sa_two用户权限。我通常使用一组SQL命令是这样的:

create tablespace my_data 
datafile 'C:\Oracle\oradata\orcl\my_data.dbf' size 50m 
autoextend on next 10m 
/

drop user sa_two cascade 
/

create user sa_two 
identified by mypassword 
quota unlimited on my_data 
/

grant connect, resource to sa_two 
/

如果你使用小鬼全进口,我相信你在创建表空间。

+0

我不能指定表空间为要导入的数据?如果没有,那么所有的导出数据如何保存在“系统”表空间中? – hguser