1.建立 directory
手工创建database目录
create or replace directory dir as '/data/oracle'
查询有哪些directory
select directory_name,directory_path from dba_directories;
赋权
grant read,write on directory dir to user;
2.1数据泵导表
expdp help=y
expdp scott/tiger directory=dir dumpfile=expdp_scott1.dmp tables=emp,dept
2.2导入 scott 的表
drop table emp purge;
drop table dept purge;
impdp help=y
impdp scott/tiger directory=dir dumpfile=expdp_scott1.dmp
3.1导出 scott 的 emp1 的数据,但不导出结构
expdp scott/tiger directory=dir dumpfile=expdp_scott1.dmp tables=emp1 content=data_only reuse_dumpfiles=y
3.2导入 Scott 的表数据,只导入数据
truncate table emp1;
impdp scott/tiger directory=dir dumpfile=expdp_scott1.dmp
4.1导出表中部分行
expdp scott/tiger directory=dir dumpfile=expdp_emp.dmp tables=emp query="'where deptno = 10'"
4.2导入为其他表名
impdp scott/tiger directory=dir dumpfile=expdp_emp.dmp remap_table=emp:emp10
5.1数据泵导用户
expdp system/oracle directory=dir dumpfile=scott.dmp schemas=scott
5.2将对象导入其他用户名
impdp system/oracle directory=dir dumpfile=scott.dmp remap_schema=scott:test
6.数据泵可传输表空间
6.1检查自包含
EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('TBS1', TRUE);
SELECT * FROM TRANSPORT_SET_VIOLATIONS;
当前表空间中的对象不依赖该表空间之外的对象。
例如:有 TEST 表空间,里面有个表叫 T1,如果在 T1 上建个索引叫 T1_idx,而这个索引建在 USERS
表空间上,由于 T1_idx 索引是依赖 T1 表的,
那么,TEST 表空间是自包含的,可以迁移,但会甩掉 T1_idx 索引,USERS 表空间不是自包含
的,不符合迁移条件。
6.2表空间只读
alter tablespace tbs1 read only;
6.3导出表空间
expdp system/oracle directory=dir dumpfile=expdp_tbs1.dmp transport_tablespaces=tbs1
6.4scp 到目标端
scp expdp_tbs1.dmp ip:/data/oracle/dir
scp /u01/app/oracle/oradata/PROD/tbs1.dfb ip:/u01/app/oracle/oradata/EMREP/
6.5目标端创建对应用户
grant connect,resource to damon identified by oracle;
6.6目标端
导入
impdp system/oracle directory=dir dumpfile=expdp_tbs1.dmp TRANSPORT_DATAFILES=/u01/app/oracle/oradata/EMREP/tbs1.dfb
6.7两端
read wirte
alter tablespace tbs1 read write;
select tablespace_name,status from dba_tablespaces;