|
如何让oracle数据库能自动备份?
环境:linux + oracle
假如数据库的实例名是oracle245,用户名是hhris,密码是hhris,要备份的目录是linux系统的根目录"/",通常我们的用dos命令来操作的,具体命令如下:
exp [email=hhris/hhris@oracle245]hhris/hhris@oracle245[/email] file=/oracle245.dmp
但是这样写的文件名是死的,如果我们把命令略加修改,就能生成以日期来命名的文件名:
exp [email=hhris/hhris@Oracle245]hhris/hhris@Oracle245[/email] file=/%date:~0,4%%date:~5,2%%date:~8,2%.dmp
然后把该命令添加到系统的任务中去,就能自动备份数据库了
导入命令:
imp [email=hhris/hhris@oracle245]hhris/hhris@oracle245[/email] file=/oracle245.dmp
========================================================
3.0中,如果要导出
exp system/system file=hhpacs.dmp tables=(accesshold,accesstable,applicationentity,devaccess,device,face,groupnames,securitymatrix,storageaccess,storagecontrol,transmiting,useraccess,patientlevel,studylevel,serieslevel,imagelevel,instancetable,studylevel_old,serieslevel_old,imagelevel_old,instancetable_old) owner=system direct=y log=exp_hhpacs.log
exp hhris/hhris file=hhris.dmp owner=hhris direct=y log=exp_hhris.log
exp hhus/hhus file=hhus.dmp owner=hhus direct=y log=exp_hhus.log
exp hhendo/hhendo file=hhendo.dmp owner=hhendo direct=y log=exp_hhendo.log
==========================================================
4.0中,如果要导出
exp hhapcs/hhpacs file=/zw/hhpacs.dmp owner=hhpacs direct=y log=exp_hhpacs.log
exp hhris/hhris file=/zw/hhris.dmp owner=hhris direct=y log=exp_hhris.log
==========================================================
导入
$sqlplus /”as sysdba”
Sql>create user hhpacs identified by hhpacs default tablespace hhpacs;
Sql>create user hhris identified by hhris default tablespace hhris;
Sql>grant dba to hhpacs;
Sql>grant dba to hhris;
Sql>exit
$imp hhris/hhris file=hhris.dmp fromuser=hhris buffer=40960000 log=imp_hirs.log
$imp hhpacs/hhpacs file=hhpacs.dmp fromuser=hhpacs buffer=40960000 log=imp_hhpacs.log
===========================================================
imp hhpacs/hhpacs file=/zw/hhpacs.dmp fromuser=hhpacs touser=hhpacs log=imp_hhpacs.log
imp hhris/hhris file=/zw/hhris.dmp fromuser=hhris touser=hhris log=imp_hhris.log |
|