Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Populating timestamp intervals

BeefStuJan 17 2022

I am trying to generate some data to populate a timestamp. My goal is to have 15 minute intervals between each row and populate the digits after the decimal so the fractional part isn't always .000000

Below is my attempt. Any SQL or mathematical help would be greatly appreciated.
Thanks in advance to all who answer.

CREATE TABLE t3 (
seq_num NUMBER  GENERATED BY DEFAULT AS IDENTITY (START WITH 1) NOT NULL,
dt TIMESTAMP)
  PARTITION BY RANGE (dt) 
  INTERVAL ( NUMTODSINTERVAL (1, 'DAY') ) ( 
    PARTITION OLD_DATA VALUES LESS THAN (TIMESTAMP '2022-01-01 00:00:00.000000')
  );
/

INSERT into t3 (dt)
with dt (dt, interv) as (
select date '2022-01-01', numtodsinterval(15,'MINUTE') +  numtodsinterval((1+rownum/(24*60*60*2)),'SECOND')from dual
union all
select dt.dt + interv, interv from dt
where dt.dt + interv < date '2022-01-15')
select dt from dt;
/
This post has been answered by Frank Kulash on Jan 17 2022
Jump to Answer
Comments
Post Details
Added on Jan 17 2022
5 comments
488 views