同一数据库,同一实例,导出表空间导入到另一个用户的新表空间
不建议用EXP/IMP,使用expdp/impdp
例子:
create temporary tablespace TXXX_TEMP tempfile
'/home/data/oradata/ORCL/TXXX_temp.dbf' size 200m autoextend on
maxsize unlimited extent management local; //创建临时表空间
create tablespace TXXX_DATA logging datafile
'/home/data/oradata/ORCL/TXXX_data01.dbf' size 200m autoextend on
next 200m maxsize 32767M extent management local; //创建表空间
create user TXXX identified by xxxxxxx default tablespace
TXXX_DATA temporary tablespace TXXX_TEMP; //创建用户指定表空间
CREATE OR REPLACE DIRECTORY expdir AS '/tmp';
//创建目录夹供导入导出参数使用
select * from dba_directories; //查询是否成功
grant read,write on directory expdir to JAXXX;
//赋给导出用户此文件夹权限
grant read,write on directory expdir to TXXX;
//赋给导入用户此文件夹权限
grant export full database to TXXX;
//赋给新用户权限
grant import full database to TXXX; //赋给新用户权限
grant connect,resource to TXXX; //赋给新用户权限
grant create procedure to TXXX; //赋给新用户权限
grant create job to TXXX; //赋给新用户权限
grant create view to TXXX; //赋给新用户权限
grant create synonym to TXXX; //赋给新用户权限
----如果怕权限不够出现错误,执行如下----
grant connect,resource,dba to TXXX;
GRANT IMP_FULL_DATABASE to TXXX;
grant resource to TXXX
//再次授权才可有创建表的权限
------------------------------------------
导出:
expdp JAXXX/xxxxxx@ORCL directory=expdir
dumpfile=jiahuaexpdp.dmp logfile=exp.log
错误:ORA-39181: Only partial table data may be exported due to
fine grain access control on
赋予权限: Grant EXEMPT ACCESS POLICY to JAXXX;
导入:
impdp TXXX/xxxxxx dumpfile=jiahuaexpdp.dmp directory=expdir
remap_schema=JAXXX:TXXX remap_tablespace=JAXXX_DATA:TXXX_DATA
参数说明
dumpfile:需要导入的dmp文件名称
directory:dmp文件所在的目录文件夹
REMAP_SCHEMA: 该选项用于将源方案的所有对象装载到目标方案中。
REMAP_SCHEMA=source_schema:target_schema
REMAP_TABLESPACE: 将源表空间的所有对象导入到目标表空间中。
REMAP_TABLESPACE=source_tablespace:target_tablespace