Oracle批量插入有日期类型数据
例如现在有张表
id(number) | startTime(date) | name(varchar2) |
1 | 2017-08-13 | zhangsan |
2 | 2017-08-14 | zhangsan |
需要批量插入name为zhangsan,日期以天递增,一个月的数据
1 insert into t(id,date,name) 2 select level,trunc(current_timestamp)+level,'zhangsan' 3 from dual 4 connect by level<= add_months(trunc(current_timestamp),1)-trunc(current_timestamp)
add_months(time,months)
Oracle的自带的日期函数,在time这个时间上增加或减少months个月
select add_months(current_timestamp,6) from dual --在当前时间加上半年 select add_months(current_timestamp,-1) from dual --在当前时间减去一个月
connect by 用法 http://blog.csdn.net/wang_yunj/article/details/51040029