很多人在进行数据迁移时,希望把数据导入不同于原系统的表空间,在导入之后却往往发现,数据被导入了原表空间
2010-07-01 10:10
441 查看
很多人在进行数据迁移时,希望把数据导入不同于原系统的表空间,在导入之后却往往发现,数据被导入了原表空间。
很多人在进行数据迁移时,希望把数据导入不同于原系统的表空间,在导入之后却往往发现,数据被导入了原表空间。
本例举例说明解决这个问题:
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.
如果用户已经具有sysdba角色的话就只需要执行以下3步就可以啦!
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
3.重新导入数据
$ 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.
现在数据被导入到正确的用户表空间中. -----
如何已经导入完毕采用下面方式来更换表空间,同时上面的方法也存在一定对表空间规划的问题
另外如果你已经在没有运行以上命令时就已将数据给导入后还可通过alter方式来对表以及索引进行表空间规划.
1:先通过:SELECT 'ALTER INDEX '||INDEX_NAME||' REBUILD TABLESPACE tablespace_name;' FROM USER_INDEXES;语句来得到一个SQL脚本文件.
2:然后在pl/sql developer工具中执行操作即可.
3:当在执行过程中可能会遇到一些不能重新编译的情况,这时可以将这些暂不能编译的放在最后面执行即可.
更改表的所属表空间:alter table a move tablespace tbsname;补充:移动完毕后需重建索引.alte index idx_name rebuild tablespace tablespace_name;
补:在实际应用中遇到了另一种情况就是当按上面第一种方案进行数据导入以后所有的信息全在一个表空间下,这样对于表空间规划不太合理,为了进一步对表空间的规划,又在第一种方案下采用方案二对表空间进行规划,当执行方案二中得到的SQL语句执行时会报出:ORA-01950 no privileges on tablespace 'workindex'这样错误提示,这只要是由于方案一中的alter命令所造成的,可能通过:alter user workflow quota unlimited on workinedx;语句来使workflow用户在workindex表空间上也具有无限制配额即可.然后再执行方案二中得到的alter的SQL脚本!
以下是我工作过程中所使用的导出导入语句
导入语句
导入采用命令行,有利于产生log文件
imp workflow/workflow@WORKFLOW file = /setup/workflow.dmp fromuser=workflow touser=workflow show=n buffer=2048000 ignore=n commit=y grants=y full=n log=/tmp/imp_workflw.log
imp workflow/workflow@WORKFLOW file=/oracle/installfiles/workflow.dmp fromuser=workflow touser=workflow show=n buffer=2048000 ignore=n commit=y grants=y full=n log=/oracle/installfiles/imp_workflw.log
imp workflow/workflow file=/oracle/installfiles/workflow.dmp fromuser=WF9 touser=workflow show=n buffer=2048000 ignore=n commit=y grants=y full=n log=/oracle/installfiles/imp_workflw.log
导入导出Windows下使用以下为IMP/EXP导入导出命令工具在项目中一些常用的方式如下:
1:导出整个方案库
EXP username/password@database FILE=D:filename.dmp log=D:filename.log
2:导入整个方案库 --当源库中存在表或其它信息内容可加入ROWS=Y IGNORE=Y这两个参数--
IMP username/password@database file=D:filename.dmp log=D:filename.log fromuser=exp_username touser=imp_username;
3:导出方案中部分表信息
EXP username/password@database tables=(table_name1,table_name2,table_name3,...) file=D:filename.dmp log=D:filename.log
4:导入方案中部分表信息 --同上--
IMP username/password@database tables=(table_name1,table
文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/7_databases/oracle/oraclejs/2008827/138106.html
很多人在进行数据迁移时,希望把数据导入不同于原系统的表空间,在导入之后却往往发现,数据被导入了原表空间。
本例举例说明解决这个问题:
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.
如果用户已经具有sysdba角色的话就只需要执行以下3步就可以啦!
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
3.重新导入数据
$ 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.
现在数据被导入到正确的用户表空间中. -----
如何已经导入完毕采用下面方式来更换表空间,同时上面的方法也存在一定对表空间规划的问题
另外如果你已经在没有运行以上命令时就已将数据给导入后还可通过alter方式来对表以及索引进行表空间规划.
1:先通过:SELECT 'ALTER INDEX '||INDEX_NAME||' REBUILD TABLESPACE tablespace_name;' FROM USER_INDEXES;语句来得到一个SQL脚本文件.
2:然后在pl/sql developer工具中执行操作即可.
3:当在执行过程中可能会遇到一些不能重新编译的情况,这时可以将这些暂不能编译的放在最后面执行即可.
更改表的所属表空间:alter table a move tablespace tbsname;补充:移动完毕后需重建索引.alte index idx_name rebuild tablespace tablespace_name;
补:在实际应用中遇到了另一种情况就是当按上面第一种方案进行数据导入以后所有的信息全在一个表空间下,这样对于表空间规划不太合理,为了进一步对表空间的规划,又在第一种方案下采用方案二对表空间进行规划,当执行方案二中得到的SQL语句执行时会报出:ORA-01950 no privileges on tablespace 'workindex'这样错误提示,这只要是由于方案一中的alter命令所造成的,可能通过:alter user workflow quota unlimited on workinedx;语句来使workflow用户在workindex表空间上也具有无限制配额即可.然后再执行方案二中得到的alter的SQL脚本!
以下是我工作过程中所使用的导出导入语句
导入语句
导入采用命令行,有利于产生log文件
imp workflow/workflow@WORKFLOW file = /setup/workflow.dmp fromuser=workflow touser=workflow show=n buffer=2048000 ignore=n commit=y grants=y full=n log=/tmp/imp_workflw.log
imp workflow/workflow@WORKFLOW file=/oracle/installfiles/workflow.dmp fromuser=workflow touser=workflow show=n buffer=2048000 ignore=n commit=y grants=y full=n log=/oracle/installfiles/imp_workflw.log
imp workflow/workflow file=/oracle/installfiles/workflow.dmp fromuser=WF9 touser=workflow show=n buffer=2048000 ignore=n commit=y grants=y full=n log=/oracle/installfiles/imp_workflw.log
导入导出Windows下使用以下为IMP/EXP导入导出命令工具在项目中一些常用的方式如下:
1:导出整个方案库
EXP username/password@database FILE=D:filename.dmp log=D:filename.log
2:导入整个方案库 --当源库中存在表或其它信息内容可加入ROWS=Y IGNORE=Y这两个参数--
IMP username/password@database file=D:filename.dmp log=D:filename.log fromuser=exp_username touser=imp_username;
3:导出方案中部分表信息
EXP username/password@database tables=(table_name1,table_name2,table_name3,...) file=D:filename.dmp log=D:filename.log
4:导入方案中部分表信息 --同上--
IMP username/password@database tables=(table_name1,table
文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/7_databases/oracle/oraclejs/2008827/138106.html
相关文章推荐
- 希望把数据导入不同于原系统的表空间
- ORACLE把数据导入不同于原系统的表空间
- Java 使用poi导入excel,结合xml文件进行数据验证的例子(增加了jar包)
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台(C#开发)-系统需求分析
- PLSQL数据导入导出问题解决(空表、大字段表、表空间错误等)
- 使用Transact-SQL进行数据导入导出方法详解
- 模块管理常规功能自定义系统的设计与实现(09--数据新增[二、单条数据导入])
- 使用SQLyog在进行l批量Mysql数据导入时报错解决方法
- HBase数据迁移(2)- 使用bulk load 工具从TSV文件中导入数据
- Android中如何将清除数据变为管理空间进行自定义数据清除
- SQL Server BI Step by Step 2--- 使用SSIS进行简单的数据导入导出
- 在 Linux 下用户空间与内核空间数据交换的方式,第 1 部分: 内核启动参数、模块参数与sysfs、sysctl、系统调用和netlink
- 请教各位大侠:利用数据管道进行数据迁移时碰到的问题。
- C# WinFrom 用Execl做模版进行数据导入
- 对应用系统部分数据进行增量更新
- 小米手机 更新系统之后(MIUI 7.2稳定版) 拍照上传返回 取不到数据问题!
- python对MySQL进行数据的插入、更新和删除之后需要commit,数据库才会真的有数据操作。(待日后更新)
- 导入空间数据到Postgis数据库的问题
- 【DRP】将SQL脚本导入Oracle数据库并进行数据初始化
- 【转】DB2 BLOB大字段数据通过命令行进行导入导出