通过job来实现 每天执行以下sql语句 insert into 退宿表 select * from 入住表 where trunc(sysdate-intime)>=20; delete from 入住表 where trunc(sysdate-intime)>=20; insert into 历史表 select * from 退宿表 where trunc(sysdate-outtime)>=20; delete from 退宿表 where trunc(sysdate-intime)>=20;
每天执行以下sql语句
insert into 退宿表 select * from 入住表 where trunc(sysdate-intime)>=20;
delete from 入住表 where trunc(sysdate-intime)>=20;
insert into 历史表 select * from 退宿表 where trunc(sysdate-outtime)>=20;
delete from 退宿表 where trunc(sysdate-intime)>=20;
问题:有3张表 入住表(intime varchar(20)[入表时间],outtime varchar(20)[退出表时间])
退宿表(intime varchar(20),outtime varchar(20))
历史表(intime varchar(20),outtime varchar(20))
实现: 如果目前系统时间与入表时间的差值大与20天,
满足该条件记录进入退宿表,删除入住表 的记录
如果记录在退宿表中的时间大与20天,
满足该条件的记录进入历史表,删除原来退宿表中的记录。
现在看懂了吗?
看不懂我的话,我要晕了~!
结帖~!