当前位置:Gxlcms > mysql > expdp&impdp

expdp&impdp

时间:2021-07-01 10:21:17 帮助过:31人阅读

1 创建逻辑目录,该命令不会在操作系统创建真正的目录,最好以system等管理员创建。 create directory dpdata1 as '/opt/oracle/dpdata1'; create directory expdata as '/ora_arch/expdata'; 2 查看管理理员目录(同时查看操作系统是否存在,因为Oracle并不

1 创建逻辑目录,该命令不会在操作系统创建真正的目录,最好以system等管理员创建。
create directory dpdata1 as '/opt/oracle/dpdata1';
create directory expdata as '/ora_arch/expdata';

2 查看管理理员目录(同时查看操作系统是否存在,因为Oracle并不关心该目录是否存在,如果不存在,则出错)
select * from dba_directories;

3 给scott用户赋予在指定目录的操作权限,最好以system等管理员赋予。
grant read,write on directory expdata to ardb;

4 导出数据
1)按用户导
expdp billingcdrdb/billingcdrdb@prodbillingcdrdb schemas=billingcdrdb dumpfile=prodbillingcdrdb.dmp directory=dpdata1 logfile=prodbillingcdrdb.log;
expdp billingcdrdb/billingcdrdb@prodbillingcdrdb schemas=billingcdrdb dumpfile=prodbillingcdrdb.dmp directory=dumpdir CONTENT=METADATA_ONLY logfile=prodbillingcdrdb.log;
2)并行进程parallel
expdp scott/tiger@orcl directory=dpdata1 dumpfile=scott3.dmp parallel=40 job_name=scott3
3)按表名导
expdp ardb/ardb TABLES=log_trx_detail dumpfile=log_trx_detail.dmp DIRECTORY=expdata;
4)按查询条件导
expdp scott/tiger@orcl directory=dpdata1 dumpfile=expdp.dmp Tables=emp query='WHERE deptno=20';
5)按表空间导
expdp system/manager DIRECTORY=dpdata1 DUMPFILE=tablespace.dmp TABLESPACES=temp,example;
6)导整个数据库
expdp system/manager DIRECTORY=dpdata1 DUMPFILE=full.dmp FULL=y;

5 还原数据
1)导到指定用户下
impdp scott/tiger DIRECTORY=dpdata1 DUMPFILE=expdp.dmp SCHEMAS=scott;
2)改变表的owner
impdp system/manager DIRECTORY=dpdata1 DUMPFILE=expdp.dmp TABLES=scott.dept REMAP_SCHEMA=scott:system;
3)导入表空间
impdp system/manager DIRECTORY=dpdata1 DUMPFILE=tablespace.dmp TABLESPACES=example;
4)导入数据库
impdb system/manager DIRECTORY=dump_dir DUMPFILE=full.dmp FULL=y;
5)追加数据
impdp system/manager DIRECTORY=dpdata1 DUMPFILE=expdp.dmp SCHEMAS=system TABLE_EXISTS_ACTION

drop user algeria cascade ;
create user algeria identified by algeria default tablespace algeria ;
grant connect , resource to algeria ;
grant create synonym , create view to algeria ;
create directory algeria as 'd:\algeria';
impdp billingcdrdb1/billingcdrdb1 directory=dpdata1 dumpfile=prodbillingcdrdb.dmp remap_schema=billingcdrdb:billingcdrdb1 logfile=impdp.log

人气教程排行