connect by level과
trunc(sysdate) 개념이 합쳐져서..
구글링의 결과 만세
select level,to_char(trunc(sysdate) + (level-1)/24, 'YYYY-MM-DD HH24:MI') AS SysDater,to_char(trunc(sysdate) + (level-1)/24, 'HH24:MI') AS SysHour
from dual connect by level <= 24;
select level,to_char(trunc(sysdate) + (level-1)/24, 'YYYY-MM-DD HH24:MI') AS SysDater
from dual connect by level <= 24;
select to_char(trunc(sysdate) + 0.012 , 'YYYY-MM-DD HH24:MI') AS SysDater
from dual connect by level <= 24;
select to_char(trunc(sysdate) + (level-1)/24, 'YYYY-MM-DD HH24:MI') AS SysDater
from dual connect by level <= 24;
select to_char(trunc(sysdate) + (level-1)/1440, 'YYYY-MM-DD HH24:MI') AS SysDater
from dual connect by level <= 24;
select to_char(trunc(sysdate) + (level-1)/1440, 'YYYY-MM-DD HH24:MI') AS SysDater
from dual connect by level <= 1440;
select to_char(trunc(sysdate) + (level-1)/86400, 'YYYY-MM-DD HH24:MI:SS') AS SysDater
from dual connect by level <= 86400;
select to_char(trunc(sysdate) + (level-1)/86400, 'YYYY-MM-DD HH24:MI:SS') AS SysDater
from dual connect by level <= 20000;
-- 3일치 하루에 2건씩은 어케하냐.. 아래는 안됨.
select to_char(trunc(sysdate) + ((level-1) + 86400-20000)/86400, 'YYYY-MM-DD HH24:MI:SS') AS SysDater
from dual
connect by level <= 60000;
-- 4초마다 하나의 데이터 생성하기
-- 86400/4 = 21600. 즉, 하루에 21600건씩 조회가능!! wow
select to_char(trunc(sysdate) + (level-1)/86400 * 4, 'YYYY-MM-DD HH24:MI:SS') AS SysDater
from dual connect by level <= 20000;
asktom.oracle.com/pls/apex/f?p=100:11:::NO::P11_QUESTION_ID:9540408400346045219
'데이터베이스 > ORACLE' 카테고리의 다른 글
[Oracle] ORA-30009: Not enough memory for CONNECT BY operation (0) | 2020.09.13 |
---|---|
[Oracle] 두 테이블 곱하기 : 길이가 다른 테이블을 from절에 두면, 두개의 테이블이 곱해진다 (랜덤 데이터 생성에 응용) (0) | 2020.09.12 |
[Oracle] DATE 타입의 컬럼이 2018/01/01으로 보여도 초 데이터까지 있다. (0) | 2020.09.12 |
[ORACLE] TO_CHAR, TO_DATE 함수로 초까지 나타내기 (0) | 2020.09.12 |
[Oracle] SQL Developer 엑셀 import 하기 (0) | 2020.09.07 |