SQL语句怎么删除指定日期的数据

如题所述

你的字段里面,必须有个记录日期的吧
以Oracle为例
如果你的记录日期的字段为字符串类型的
delete
from
T1
where
T1.dateCol='2012-11-06'
如果你的记录日期的字段为日期类型的
delete
from
T1
where
to_char(T1.dateCol,'yyyy-mm-dd')='2012-11-06'
如果记录日期的长度比较长,那就截取字符串,使用substr函数
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-04-01
删除指定日期后的记录
sql语句:
以删除2004年8月4日到2006年10月25日的数据为例:
delete
from
tb
where
columnname
between
'2004/8/5'
and
'2006/10/25'
如果记录日期的字段为字符串类型的
delete
from
t1
where
t1.datecol='2012-11-06'
如果记录日期的字段为日期类型的
delete
from
t1
where
to_char
(t1.datecol,'yyyy-mm-dd')='2012-11-06'
如果记录日期的长度比较长,那就截取字符串,使用
substr函数
第2个回答  2020-02-06
删除指定日期后的记录
sql语句:
以删除2004年8月4日到2006年10月25日的数据为例:
delete
from
tb
where
columnname
between
'2004/8/5'
and
'2006/10/25'
如果记录日期的字段为字符串类型的
delete
from
t1
where
t1.datecol='2012-11-06'
如果记录日期的字段为日期类型的
delete
from
t1
where
to_char(t1.datecol,'yyyy-mm-dd')='2012-11-06'
如果记录日期的长度比较长,那就截取字符串,使用substr函数。
相似回答