The format mask in to_date()
must be enclosed within single quotes too.
To produce the output in string format you need to apply to_char()
with the same format mask.
select to_char(to_date('20160101', 'YYYYMMDD') + level - 1, 'YYYYMMDD') as dt
from dual
connect by level <= 1 + to_date('20160104', 'YYYYMMDD') - to_date('20160101', 'YYYYMMDD')
;
DT
--------
20160101
20160102
20160103
20160104
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…