怎样修改oracle表空间?
我从一个数据库导出的test.dmp格式的文件。但是这个表空间是a,我现在要把这些表导入用户名为:admin,密码为:pass但表空间为b的数据库Oracle中,要是这样...
我从一个数据库导出的test.dmp格式的文件。但是这个表空间是a,我现在要把这些表导入用户名为:admin,密码为:pass但表空间为b的数据库Oracle中,要是这样:imp admin/pass@Oracle file =E:\test.dmp full = y;导入,可是这些表空间还是a表空间就不一致了,我想修改下表空间是b,怎么做呢?
展开
4个回答
展开全部
很多人在进行数据迁移时,希望把数据导入不同于原系统的表空间,在导入之后却往往发现,数据被导入了原表空间。
本例举例说明解决这个问题:
1.如果缺省的用户具有DBA权限
那么导入时会按照原来的位置导入数据,即导入到原表空间
$ imp bjbbs/passwd file=bj_bbs.dmp fromuser=jive touser=bjbbs grants=n
Import: Release 8.1.7.4.0 - Production on Mon Sep 22 11:49:41 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
Export file created by EXPORT:V08.01.07 via conventional path
Warning: the objects were exported by JIVE, not by you
import done in ZHS16GBK character set and ZHS16GBK NCHAR character set
. . importing table "HS_ALBUMINBOX" 12 rows imported
. . importing table "HS_ALBUM_INFO" 47 rows imported
. . importing table "HS_CATALOG" 13 rows imported
. . importing table "HS_CATALOGAUTHORITY" 5 rows imported
. . importing table "HS_CATEGORYAUTHORITY" 0 rows imported
....
. . importing table "JIVEUSERPROP" 4 rows imported
. . importing table "JIVEWATCH" 0 rows imported
. . importing table "PLAN_TABLE" 0 rows imported
. . importing table "TMZOLDUSER" 3 rows imported
. . importing table "TMZOLDUSER2" 3 rows imported
About to enable constraints...
Import terminated successfully without warnings.
查询发现仍然导入了USER表空间
$ sqlplus bjbbs/passwd
SQL*Plus: Release 8.1.7.0.0 - Production on Mon Sep 22 11:50:03 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
SQL> select table_name,tablespace_name from user_tables;
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
HS_ALBUMINBOX USERS
HS_ALBUM_INFO USERS
HS_CATALOG USERS
HS_CATALOGAUTHORITY USERS
HS_CATEGORYAUTHORITY USERS
HS_CATEGORYINFO USERS
HS_DLF_DOWNLOG USERS
...
JIVEWATCH USERS
PLAN_TABLE USERS
TMZOLDUSER USERS
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
TMZOLDUSER2 USERS
45 rows selected.
2.回收用户unlimited tablespace权限
这样就可以导入到用户缺省表空间
SQL> create user bjbbs identified by passwd
2 default tablespace bjbbs
3 temporary tablespace temp
4 /
User created.
SQL> grant connect,resource to bjbbs;
Grant succeeded.
SQL> grant dba to bjbbs;
Grant succeeded.
SQL> revoke unlimited tablespace from bjbbs;
Revoke succeeded.
SQL> alter user bjbbs quota 0 on users;
User altered.
SQL> alter user bjbbs quota unlimited on bjbbs;
User altered.
SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
重新导入数据
$ imp bjbbs/passwd file=bj_bbs.dmp fromuser=jive touser=bjbbs grants=n
Import: Release 8.1.7.4.0 - Production on Mon Sep 22 12:00:51 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
Export file created by EXPORT:V08.01.07 via conventional path
Warning: the objects were exported by JIVE, not by you
import done in ZHS16GBK character set and ZHS16GBK NCHAR character set
. . importing table "HS_ALBUMINBOX" 12 rows imported
. . importing table "HS_ALBUM_INFO" 47 rows imported
. . importing table "HS_CATALOG" 13 rows imported
. . importing table "HS_CATALOGAUTHORITY" 5 rows imported
. . importing table "HS_CATEGORYAUTHORITY" 0 rows imported
. . importing table "HS_CATEGORYINFO" 9 rows imported
. . importing table "HS_DLF_DOWNLOG" 0 rows imported
....
. . importing table "JIVEUSER" 102 rows imported
. . importing table "JIVEUSERPERM" 81 rows imported
. . importing table "JIVEUSERPROP" 4 rows imported
. . importing table "JIVEWATCH" 0 rows imported
. . importing table "PLAN_TABLE" 0 rows imported
. . importing table "TMZOLDUSER" 3 rows imported
. . importing table "TMZOLDUSER2" 3 rows imported
About to enable constraints...
Import terminated successfully without warnings.
SQL> select table_name,tablespace_name from user_tables;
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
HS_ALBUMINBOX BJBBS
HS_ALBUM_INFO BJBBS
HS_CATALOG BJBBS
HS_CATALOGAUTHORITY BJBBS
....
JIVETHREAD BJBBS
JIVETHREADPROP BJBBS
JIVEUSER BJBBS
JIVEUSERPERM BJBBS
JIVEUSERPROP BJBBS
JIVEWATCH BJBBS
PLAN_TABLE BJBBS
TMZOLDUSER BJBBS
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
TMZOLDUSER2 BJBBS
45 rows selected.
本例举例说明解决这个问题:
1.如果缺省的用户具有DBA权限
那么导入时会按照原来的位置导入数据,即导入到原表空间
$ imp bjbbs/passwd file=bj_bbs.dmp fromuser=jive touser=bjbbs grants=n
Import: Release 8.1.7.4.0 - Production on Mon Sep 22 11:49:41 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
Export file created by EXPORT:V08.01.07 via conventional path
Warning: the objects were exported by JIVE, not by you
import done in ZHS16GBK character set and ZHS16GBK NCHAR character set
. . importing table "HS_ALBUMINBOX" 12 rows imported
. . importing table "HS_ALBUM_INFO" 47 rows imported
. . importing table "HS_CATALOG" 13 rows imported
. . importing table "HS_CATALOGAUTHORITY" 5 rows imported
. . importing table "HS_CATEGORYAUTHORITY" 0 rows imported
....
. . importing table "JIVEUSERPROP" 4 rows imported
. . importing table "JIVEWATCH" 0 rows imported
. . importing table "PLAN_TABLE" 0 rows imported
. . importing table "TMZOLDUSER" 3 rows imported
. . importing table "TMZOLDUSER2" 3 rows imported
About to enable constraints...
Import terminated successfully without warnings.
查询发现仍然导入了USER表空间
$ sqlplus bjbbs/passwd
SQL*Plus: Release 8.1.7.0.0 - Production on Mon Sep 22 11:50:03 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
SQL> select table_name,tablespace_name from user_tables;
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
HS_ALBUMINBOX USERS
HS_ALBUM_INFO USERS
HS_CATALOG USERS
HS_CATALOGAUTHORITY USERS
HS_CATEGORYAUTHORITY USERS
HS_CATEGORYINFO USERS
HS_DLF_DOWNLOG USERS
...
JIVEWATCH USERS
PLAN_TABLE USERS
TMZOLDUSER USERS
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
TMZOLDUSER2 USERS
45 rows selected.
2.回收用户unlimited tablespace权限
这样就可以导入到用户缺省表空间
SQL> create user bjbbs identified by passwd
2 default tablespace bjbbs
3 temporary tablespace temp
4 /
User created.
SQL> grant connect,resource to bjbbs;
Grant succeeded.
SQL> grant dba to bjbbs;
Grant succeeded.
SQL> revoke unlimited tablespace from bjbbs;
Revoke succeeded.
SQL> alter user bjbbs quota 0 on users;
User altered.
SQL> alter user bjbbs quota unlimited on bjbbs;
User altered.
SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
重新导入数据
$ imp bjbbs/passwd file=bj_bbs.dmp fromuser=jive touser=bjbbs grants=n
Import: Release 8.1.7.4.0 - Production on Mon Sep 22 12:00:51 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
Export file created by EXPORT:V08.01.07 via conventional path
Warning: the objects were exported by JIVE, not by you
import done in ZHS16GBK character set and ZHS16GBK NCHAR character set
. . importing table "HS_ALBUMINBOX" 12 rows imported
. . importing table "HS_ALBUM_INFO" 47 rows imported
. . importing table "HS_CATALOG" 13 rows imported
. . importing table "HS_CATALOGAUTHORITY" 5 rows imported
. . importing table "HS_CATEGORYAUTHORITY" 0 rows imported
. . importing table "HS_CATEGORYINFO" 9 rows imported
. . importing table "HS_DLF_DOWNLOG" 0 rows imported
....
. . importing table "JIVEUSER" 102 rows imported
. . importing table "JIVEUSERPERM" 81 rows imported
. . importing table "JIVEUSERPROP" 4 rows imported
. . importing table "JIVEWATCH" 0 rows imported
. . importing table "PLAN_TABLE" 0 rows imported
. . importing table "TMZOLDUSER" 3 rows imported
. . importing table "TMZOLDUSER2" 3 rows imported
About to enable constraints...
Import terminated successfully without warnings.
SQL> select table_name,tablespace_name from user_tables;
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
HS_ALBUMINBOX BJBBS
HS_ALBUM_INFO BJBBS
HS_CATALOG BJBBS
HS_CATALOGAUTHORITY BJBBS
....
JIVETHREAD BJBBS
JIVETHREADPROP BJBBS
JIVEUSER BJBBS
JIVEUSERPERM BJBBS
JIVEUSERPROP BJBBS
JIVEWATCH BJBBS
PLAN_TABLE BJBBS
TMZOLDUSER BJBBS
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
TMZOLDUSER2 BJBBS
45 rows selected.
展开全部
IMP 可以导入不同用户,但是表空间名称是要一样。
如果是oracle 10g或以上可以用数据泵
1、expdp 导出文件
2、impdp 用户名/密码 directory='您创建的目录的名称' dumpfile='导出的文件名称' remap_schema=导出的用户名称:要导入的用户名称 remap_tablespace=导出的表空间名称:要导入的表空间名称
如果是oracle 10g或以上可以用数据泵
1、expdp 导出文件
2、impdp 用户名/密码 directory='您创建的目录的名称' dumpfile='导出的文件名称' remap_schema=导出的用户名称:要导入的用户名称 remap_tablespace=导出的表空间名称:要导入的表空间名称
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
好像不可以,除非你导出时用的是传输表空间
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
导入结束直接修改用户引用的表空间
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询