我无法将日期数据插入到仅包含“星期六”的表格中。这就是我所拥有的:
with dts as (
select date'2015-01-01'+rownum-1 dt from dual
connect by level <= 366
)
select * from dts
where to_char(dt, 'fmday') = 'saturday';
输出只是2015年“星期六”的日期。这是我想要的,但是当我试图将它插入表格时我很失落。这与example类似,唯一的区别是我只需要它在'星期六'。
我尝试编辑的示例代码:
insert into table( id, date, year, indicator)
select sequ.nextval, to_date('31-12-2018 07:00:00', 'DD-MM-YYYY HH24:MI:SS') + level, 2019, 'X' from dual connect by level <= 365
日期部分是我遇到麻烦的地方。
这是你想要的吗?
insert into table (id, date, year, indicator)
with dts as (
select (date '2015-01-01' + rownum - 1) as dt
from dual
connect by level <= 366
)
select sequ.nextval, dt, extract(year from dt), 'X'
from dts
where to_char(dt, 'fmday') = 'saturday';
它基本上使用生成日期的查询来生成insert
的数据。