备份Oracl数据库.bat

===========================
@echo off   
echo ================================================   
echo  Windows环境下Oracle数据库的自动备份脚本  
echo  1. 使用当前日期命名备份文件。  
echo ================================================    
::设置用户名、密码和要备份的数据库。  
::set USER=detection1  
::set PASSWORD=detection1  
::set DATABASE=orcl  
::以“YYYYMMDD”格式取出当前时间。
set year=%DATE:~0,4%
rem get month 
set month=%DATE:~5,2%
rem get data 
set date=%DATE:~8,2%
rem get mydate 
set mydate=%year%%month%%date%  
::创建备份目录。
if not exist "D:\YtForever\YTPQM\DB\backup\"       mkdir D:\YtForever\YTPQM\DB\backup\   
set DATADIR=D:\YtForever\YTPQM\DB\backup\  
exp detection1/detection1@127.0.0.1/orcl  file=%DATADIR%\detection1_%mydate%.dmp
exp ytdetection1/ytdetection1@127.0.0.1/orcl  file=%DATADIR%\ytdetection1_%mydate%.dmp

exit  

 

删除>7天的文件

 

forfiles /p "D:\YtForever\YTPQM\DB\backup" /s /m *.* /d -7 /c "cmd /c del @path"

 

Oracle导出空表语句

--执行查询
select 'alter table '||table_name||' allocate extent;' from user_tables;

--执行查询结果中的语句,完成

 

posted @ 2019-11-13 09:53  章力  阅读(174)  评论(0编辑  收藏  举报