博客
关于我
oracle创建日历表,并写入数据
阅读量:395 次
发布时间:2019-03-05

本文共 1450 字,大约阅读时间需要 4 分钟。

创建日历表,并写入数据

-- Create tablecreate table tdate(  DT          DATE not null,  YEAR        number(4),  MONTH      VARCHAR2(4),  DAY         VARCHAR2(4),  WEEK         VARCHAR2(10),  WEEKNUM         VARCHAR2(4),  XQ   number(2),  QR    number(2),  bourse_week  VARCHAR2(4));insert into tdate t (  t.dt,                        t.year,                        t.month,                        t.day,                        t.week,                        t.weeknum,                        t.xq,                        t.qr,                        t.bourse_week)select trunc(everyDay) as dt,   to_char(everyday,'yyyy') as yr,   to_char(everyday,'mm') as mm,   to_char(everyday,'dd') as dd,   to_char(everyday,'dy') as dayofweek,   /*ORACLE自定义的标准周*/   to_char(everyday,'WW') as weeknum,   /*该月的第几周*/   /*lpad(to_char(everyday,'w'),6) as monthOfWeek,*/   to_char(everyday,'d') XQ,   to_char(everyday,'Q') as qr,   /*ISO的标准周,通常使用这个*/   to_char(everyday,'IW') as bourse_week   from(select to_date('20170101','yyyymmdd') + level - 1 as everyDay from dual  connect by level <=   (last_day(to_date('20220101','yyyymmdd')) - to_date('20170101','yyyymmdd') +1));  SELECT * FROM (with x as  (select add_months(trunc(sysdate, 'y'), -12) + level - 1 tdate      from dual    connect by level <=              add_months(trunc(sysdate, 'y'), 12) - trunc(sysdate, 'y')) select tdate, to_char(tdate, 'day'),rownum rn from x where to_char(tdate, 'day') ='星期五'   ) where    rn=20

转载地址:http://xrdzz.baihongyu.com/

你可能感兴趣的文章
MySQL一站到底!华为首发MySQL进阶宝典,基础+优化+源码+架构+实战五飞
查看>>
MySQL万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL不会性能调优?看看这份清华架构师编写的MySQL性能优化手册吧
查看>>
MySQL不同字符集及排序规则详解:业务场景下的最佳选
查看>>
Mysql不同官方版本对比
查看>>
MySQL与Informix数据库中的同义表创建:深入解析与比较
查看>>
mysql与mem_细说 MySQL 之 MEM_ROOT
查看>>
MySQL与Oracle的数据迁移注意事项,另附转换工具链接
查看>>
mysql丢失更新问题
查看>>
MySQL两千万数据优化&迁移
查看>>
MySql中 delimiter 详解
查看>>
MYSQL中 find_in_set() 函数用法详解
查看>>
MySQL中auto_increment有什么作用?(IT枫斗者)
查看>>
MySQL中B+Tree索引原理
查看>>
mysql中cast() 和convert()的用法讲解
查看>>
mysql中datetime与timestamp类型有什么区别
查看>>
MySQL中DQL语言的执行顺序
查看>>
mysql中floor函数的作用是什么?
查看>>
MySQL中group by 与 order by 一起使用排序问题
查看>>