一、逻辑备份(expdpimpdp)
1. 首先建立directory -- expdir(导入导出都要建立,对应的目录如果不存在,需要手工建立)
如下案例:需要备份idbuser用户下的所有表的表结构,实例名为QASIDB
create directory mydata as '/idbdata/idb/';
expdp idbuser/idbuser@QASIDB DIRECTORY=mydata CONTENT=METADATA_ONLY DUMPFILE=idbuser4.dmp logfile=idb20210317.log
参数说明:
1) CONTENT:该选项用于指定要导出的内容.默认值为ALL
CONTENT={ALL | DATA_ONLY | METADATA_ONLY}
当设置CONTENT为ALL 时,将导出对象定义及其所有数据.为DATA_ONLY时,只导出对象数据,为METADATA_ONLY时,只导出对象定义
2) DIRECTORY:指定转储文件和日志文件所在的目录:DIRECTORY=directory_object
3) idbuser/idbuser@QASIDB: 指的是 备份QASIDB实例下的idbuser用戶的数据
4)DUMPFILE备份的dump文件名称
5)logfile:保存备份过程中的日志文件
导入:
impdp idbuser/idbuser DIRECTORY=mydata CONTENT=METADATA_ONLY DUMPFILE=idbuser2.dmp logfile=idb20210314.log remap_schema=idbuser:idbuser
remap_schema:从idbuser备份而来,使用idbuser用户导入,如果是idbuser备份,hr用户导入,则写法为:remap_schema=idbuser:hr