oracle不同表空间之间的数据迁移

--将数据库为testdb,用户名为testuser中默认(users)表空间里的数据迁移至表空间(newtablespace)
--1.用system用户登陆testdb数据库,创建directory(testdir)并将读、写权限授予testuser用户
create or replace directory testdir as 'e:\temp';
grant read, write on directory testdir to testuser;
--使用expdp命令导出testuser用户的数据
expdp system/aaaaaa@testdb directory=testdir dumpfile=testdb.dmp schemas=testuser;
--2.创建表空间newtablespace
create tablespace newtablespace 
logging
datafile 'E:\oracle\product\10.2.0\oradata\oa\newtablespace.dbf' 
size 100m
autoextend on
next 200m maxsize 2048m
extent management local;
--3.将testuser的表空间修改为newtablespace
alter user testuser default tablespace newtablespace;
--4.将testuser用户下面的表、序列等删除
--5.导入数据
impdp system/aaaaaa@testdb directory=testdir dumpfile=testdb.dmp remap_tablespace=users:newtablespace

猜你喜欢

转载自adm889486.iteye.com/blog/1776923