关于Oracle中判断表中时间过期的问题
时间:2011-09-08
来源:互联网
表中存放的数据中有一列是数据的创建时间,现在我要用存储过程将其中的过期的数据删除(假设超过三天为过期),刚学数据库所以不怎么懂,请高手指点···其中进行时间比较的部分请突出一下···多谢了。
作者: easontun 发布时间: 2011-09-08
create procedure
( dt_in_time date
)
is
num_time integer :='3'; 默认过期天数
dt_time date;
begin
if (dt_in_time is null) then
dt_time :=trunc(sysdate)-num_time;
else
dt_time =trunc(dt_in_time);
end if;
delete from A where a.time < dt_time;
end
( dt_in_time date
)
is
num_time integer :='3'; 默认过期天数
dt_time date;
begin
if (dt_in_time is null) then
dt_time :=trunc(sysdate)-num_time;
else
dt_time =trunc(dt_in_time);
end if;
delete from A where a.time < dt_time;
end
作者: reg13141 发布时间: 2011-09-08
select * from table where createTime -sysdate >3
这样就可以了。。。
这样就可以了。。。
作者: ulihss 发布时间: 2011-09-08
SQL code
把1楼和2楼的合并一下就可以了
create procedure is num_time int :=3; --默认过期天数 begin delete table where createTime -sysdate >num_time; end
把1楼和2楼的合并一下就可以了
作者: rihyou 发布时间: 2011-09-08

作者: xl_smlie 发布时间: 2011-09-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28