该热备份及还原采用exp/imp方式导入导出
导出数据:
数据库导出有四种模式full(全库导出), owner(用户导出), table(表导出), tablespace(表空间导出).
full( 全库导出): 导出除ORDSYS,MDSYS,CTXSYS,ORDPLUGINS,LBACSYS 这些系统用户之外的所有用户的数据.
owner( 用户导出): 导出某个或某些用户的所有权限和数据.
tables( 表导出): 导出某些表(可以是不同用户的)的结构和数据.
tablespace( 表空间导出):表空间导出数据.
这里只是简要测试了前两种模式:
以Shell命令模式导出导入
1.将用户blog中的所有数据导出,outdata.log为导出日志记录
exp userid=system/lxf@orcl owner=blog file=d:\outdata.dmp log=d:\outdata.log;
如果数据文件较大,file=(d:\temp\outdata1.dmp, ..) filesize=2GB
2.完全导出数据库
exp userid=system/lxf@orcl full=y file=d:\outdata.dmp log=d:\outdata.log;
3.导入数据库
imp flower/lxf@orcl full=y file= d:\outdata.dmp ignore=y ;
imp system/lxf@orcl file=d:\ outdata.dmp;
imp userid=system/manager full=y file=*.dmp
表空间的导出导入,需要以sysdba德身份执行,且表空间文件为只读
SQL> ALTER TABLESPACE TEST READ ONLY;
表空间导出
exp """/@orcl as sysdba""" file=trans.dmp transport_tablespace=y tablespaces=flower_tbs triggers=n constraints=y grants=y
SQL> host exp 'sys/lxf@orcl sysdba' transport_tablespace=y file=d:\exp\tablespace.dmp tablespaces=smallts;
SQL> alter tablespace flower_tbs read write;
表空间导入
imp """/@orcl as sysdba""" file=trans.dmp transport_tablespace=y datafiles='e:\orcldatafile\smallfile.dbf ' tablespaces=test tts_owners=yangtk --用户名
SQL> host imp '/ as sysdba' transport_tablespace=y file=d:\exp\tablespace.dmp datafiles=e:\orcldatafile\smallfile.dbf fromuser=tr touser=system;
SQL> alter tablespace smallts read write;