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/[email protected] schemas=billingcdrdb dumpfile=prodbillingcdrdb.dmp directory=dpdata1 logfile=prodbillingcdrdb.log;
expdp billingcdrdb/[email protected] schemas=billingcdrdb dumpfile=prodbillingcdrdb.dmp directory=dumpdir CONTENT=METADATA_ONLY logfile=prodbillingcdrdb.log;
2)并行进程parallel
expdp scott/[email protected] 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/[email protected] 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