您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 桂林分类信息网,免费分类信息发布

Oracle创建时间维度

2025/5/25 10:34:34发布15次查看
sql scripts to create date dimension in oracle. create table sql: create table date_d( datekey integer not null, datevalue date not null, day char(10 ), dayofweek integer, dayofmonth integer, dayofyear integer, previousday date, nextday da
sql scripts to create date dimension in oracle.
create table sql:
create table date_d(
datekey integer not null,
datevalue date not null,
day char(10 ),
dayofweek integer,
dayofmonth integer,
dayofyear integer,
previousday date,
nextday date,
weekofyear integer,
month char(10 ),
monthofyear integer,
quarterofyear integer,
year integer
)
sql to populate the table:
insert into date_d
select
to_number(to_char(currdate, 'yyyymmdd')) as datekey,
currdate as datevalue,
to_char(currdate,'day') as day,
to_number(to_char(currdate,'d')) as dayofweek,
to_number(to_char(currdate,'dd')) as dayofmonth,
to_number(to_char(currdate,'ddd')) as dayofyear,
currdate - 1 as previousday,
currdate + 1 as nextday,
to_number(to_char(currdate+1,'iw')) as weekofyear,
to_char(currdate,'month') as month,
to_number(to_char(currdate,'mm')) as monthofyear,
to_number((to_char(currdate,'q'))) as quarterofyear,
to_number(to_char(currdate,'yyyy')) as year
from (
select level n, to_date('31/12/2009','dd/mm/yyyy') + numtodsinterval(level,'day') currdate
from dual
connect by level order by 1
桂林分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product