好像不行哦
%date%是环境变量参数
在DOS中怎么写函数让他减一个值,好像不行
%date%是环境变量参数
在DOS中怎么写函数让他减一个值,好像不行
解决方案 »
- 【在线急急急】装了oracle 10g和11g express两个,cmd sqlplus连接10g总是提示:TNS: 无法解析指定的连接标识符。11g没问题!
- oacle 的for循环, 运行时有个错误 求解!跪求
- 新手求助!谢谢!
- 导dmp文件时发生的错误
- 关于insert into select的问题
- 发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息
- 请教2个sql文
- 求一SQL语句,急,在线等候!ORACLE9I!谢谢
- 问一个链接的问题。
- Oracle的错误代码在哪里可以查到,如果在unix下该怎样查?在windows下呢?
- ORACLE监听不能启动!急!!!
- 将表从一个表空间迁移到另外一个表空间!
这个就是备份的完整语句.哪众位高手是怎样,在Windows环境下自动删除备份的?
get_mon_days()
{
Y=`expr substr $1 1 4`
M=`expr substr $1 5 2`r1=`expr $Y \% 4`
r2=`expr $Y \% 100`
r3=`expr $Y \% 400`case $M in
01|03|05|07|08|10|12) days=31;;
04|06|09|11) days=30;;
esac
if [ $M -eq 02 ]
then
if [ r1 -eq 0 -a r2 -ne 0 -o r3 -eq 0 ]
then
days=29
else
days=28
fi
fi
echo $days
}
#返回昨天日期
get_before_date()
{
Y=`expr substr $1 1 4`
M=`expr substr $1 5 2`
D=`expr substr $1 7 2`
YY=`expr $Y - 1`
MM=`expr $M - 1`
DD=`expr $D - 1`
MM=`printf "%02d" $MM`
DD=`printf "%02d" $DD`
dd=$Y$MM
dad=`get_mon_days $dd`
be_date=$Y$M$DD
if [ $D -eq 01 ]
then
if [ $M -ne 01 ]
then
be_date=$Y$MM$dad
fi
if [ $M -eq 01 ]
then
be_date=$YY"1231"
fi
fi
echo $be_date}
#返回明天日期
get_next_date()
{
Y=`expr substr $1 1 4`
M=`expr substr $1 5 2`
D=`expr substr $1 7 2`
YY=`expr $Y + 1`
MM=`expr $M + 1`
DD=`expr $D + 1`
MM=`printf "%02d" $MM`
DD=`printf "%02d" $DD`
r1=`expr $Y \% 4`
r2=`expr $Y \% 100`
r3=`expr $Y \% 400`next_date=$Y$M$DDif [ $D -eq 30 ]
then
case $M in
04|06|09|11) next_date=$Y$MM"01";;
esac
fi
if [ $D -eq 31 ]
then
next_date=$Y$MM"01"
case $M in
12) next_date=$YY"0101";;
esac
fi
if [ $M -eq 02 ]
then
if [ r1 -eq 0 -a r2 -ne 0 -o r3 -eq 0 ]
then
if [ $D -eq 29 ]
then
next_date=$Y$MM"01"
fi
else
if [ $D -eq 28 ]
then
next_date=$Y$MM"01"
fi
fi
fi
echo $next_date
}
方法二,用 AT 命令来做调脚本(看一下 AT 这个命令的用法)
前面两位讲的脚本是在哪里写的是指.bat档案吗,还是Oracle中.
AT命令是哪里的命令,Window还是Oracle呀!我们是想通过在.Bat档案中写命令,用windows的计划任务去执行.
或者是高手有其它的方法.
要在linux系统当中可以写shell,在crontab当中每天定时调用
那位高手可以在.Bat中写
如果怕删除了以前的.dmp文件,单又备份不成功这种情况发生,则需要这样:
1.备份
2.改名,把刚备份出来的文件改一个后缀。
3.rm *.dmp
4.再把刚才那个改回去
set head off
spool e:\auto_del.bat
select 'del e:\scott'||to_char(sysdate-1,'YYYYMMDD')||'.dmp' from dual;
spool off
set head on
2,在生成你执行删除任务的bat,就叫del_job.bat,假设也放在e:\下:
del e:\auto_del.bat
sqlplus -s Scott/tiger @auto_del.sql
auto_del.bat
3,将del_job.bat设置成你的Windows计划任务。
copy nul del_old.bat
for %%F in (e:\scott*.dmp) do echo del "%%F">>del_old.bat
exp80 user/password file=e:\scott%date:~4,4%%date:~9,2%%date:~12,2%.dmp full=y
if %ERRORLEVEL% NEQ 0 goto :END
call del_old.bat
:END
copy nul del_old.bat
rem 生成要执行的删除脚本,要删除的文件是e:\scott*.dmp
for %%F in (e:\scott*.dmp) do echo del "%%F">>del_old.bat
exp80 user/password file=e:\scott%date:~4,4%%date:~9,2%%date:~12,2%.dmp full=y
rem 如果执行exp出错则不执行删除以前的备份
if %ERRORLEVEL% NEQ 0 goto :END
rem 执行删除脚本
call del_old.bat
:END又,for的详细用法可以在cmd窗口中执行help for查看
你写的我明白了.
可是用e:\scott*.dmp哪不是把以前的备份全部都删除了.
如果我要保留N天的备份要怎么办?
exp ... file=scott.dmp
if %ERRORLEVEL% NEQ 0 goto :END
rem 保留最近三次的备份
del scott3.dmp
ren scott2.dmp scott3.dmp
ren scott1.dmp scott2.dmp
ren scott.dmp scott1.dmp
:END