当前位置:数据库 > Oracle >>

exp-imp实现oracle不同表空间的迁移

exp-imp实现oracle不同表空间的迁移
 
方法一:
 
--1、修改表空间名称(账号:sys/oracleas SYSDBA 登录)
 
alter tablespace CICHR rename to CICHR_BAK;

alter tablespace USERS rename to CICHR;

 

 
--2、导出用户
 
expcichr-20110804/cichr-20110804@db_192.168.196.232 file=cichr-232-20110804.dmplog=cichr-232-20110804-exp.log statistics = none
 
--此dmp文件表空间现在应该为CICHR
 
--3、将表空间名称修改回去(账号:sys/oracleas SYSDBA 登录)
 
alter tablespace CICHR rename to USERS;
    

alter tablespace CICHR_BAK rename to CICHR;

 

 
--4、导入到新创建用户cichr_test(默认表空间为CICHR,临时表空间为TEMP,connect\dba\resource权限,unlimited tablespace)
 
 
 
impcichr_test/cichr_test@db_192.168.196.232 file=c:\cichr-232-20110804.dmp full=ylog=c:\cichr_test-20110804-imp.log
 
或者:
 
impcichr_test/cichr_test@db_192.168.196.232 file=c:\cichr-232-20110804.dmpfromuser=cichr-20110804 touser=cichr_test tablespace=CICHRlog=c:\cichr_test-20110804-imp.log
 
至此所有数据迁移至新的表空间CICHR。
 
------------------------------------------
 
方法二:
 
1、通过PL/SQL,cichr-20110804/cichr-20110804登录,导出数据库表结构(Tools-Export User Object),导出所有用户对象到D:\structs.sql;
 
2、使用EditPlus打开structs.sql对表空间名称进行整体替换(USERS替换为CICHR),对用户名进行整体替换(cichr-20110804替换为cichr_test);
 
3、Tools-Export Tables,导出D:/data.pde (PL/SQL Developer)-所有表数据;
 
4、创建用户cichr_test(默认表空间为CICHR,临时表空间为TEMP,connect\dba\resource权限,unlimited tablespace);
 
5、Command Window,执行命令:SQL>@D:structs.sql 回车,创建数据库表结构(所属表空间为CICHR);
 
6、导入数据表数据,Tools-Import Tables,选择刚刚导出的数据文件D:/data.pde。
 
至此所有数据迁移至新的表空间CICHR。
 
-------------------------------------------
 
方法三:
 
--1、修改表空间名称(账号:sys/oracleas SYSDBA 登录)
 
alter tablespace CICHR rename to CICHR_BAK;

alter tablespace USERS rename to CICHR;

 

 
--2、通过PL/SQL,cichr_test/cichr_test登录,
 
Tools-Export Tables,导出D:/data.dmp (oracle Export)-所有表结构及表数据,现在表数据所属表空间应该为CICHR。
 
--3、将表空间名称修改回去(账号:sys/oracleas SYSDBA 登录)
 
alter tablespace CICHR rename to USERS;

alter tablespace CICHR_BAK rename to CICHR;

 

 
--4、通过PL/SQL, cichr_test/cichr_test登录,
 
1)、删除Drop 所有tables;
 
2)、Tools-Import Tables,导入D:/data.dmp(oracle Export)-所有表结构及表数据。
 
至此所有数据迁移至新的表空间CICHR。
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,