oracle工作记录
job
描述 INTERVAL参数值
每天午夜12点 ‘TRUNC(SYSDATE + 1)‘
每天早上8点30分 ‘TRUNC(SYSDATE + 1) + (8*60+30)/(24*60)‘
每星期二中午12点 ‘NEXT_DAY(TRUNC(SYSDATE ), ‘‘TUESDAY‘‘ ) + 12/24‘
每个月第一天的午夜12点 ‘TRUNC(LAST_DAY(SYSDATE ) + 1)‘
每个季度最后一天的晚上11点 ‘TRUNC(ADD_MONTHS(SYSDATE + 2/24, 3 ), ‘Q‘ ) -1/24‘
每星期六和日早上6点10分 ‘TRUNC(LEAST(NEXT_DAY(SYSDATE, ‘‘SATURDAY"), NEXT_DAY(SYSDATE, "SUNDAY"))) + (6×60+10)/(24×60)‘
--表空间使用率
SELECT Upper(F.TABLESPACE_NAME) "表空间名",
D.TOT_GROOTTE_MB "表空间大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), ‘990.99‘)
|| ‘%‘ "使用比",
F.TOTAL_BYTES "空闲空间(M)",
F.MAX_BYTES "最大块(M)"
FROM (SELECT TABLESPACE_NAME,
Round(Sum(BYTES) / ( 1024 * 1024 ), 2) TOTAL_BYTES,
Round(Max(BYTES) / ( 1024 * 1024 ), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
Round(Sum(DD.BYTES) / ( 1024 * 1024 ), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 1
alter tablespace ARVATOWMS add datafile ‘/opt/oracle/oradatas/otwb/WMS03.dbf‘ size 8000m
表大小
select round(BYTES/1024/1024,2)||‘M‘ from user_segments where segment_name=‘OMS_ORDER_LOG‘;
计算时间差
(year(CURRENT_DATE())*365*24+month(CURRENT_DATE())*30*24+day(CURRENT_DATE())*24+hour(CURRENT_TIME())+8+minute(CURRENT_TIME())/60) - (year(lastRemindDate)*365*24+month(lastRemindDate)*30*24+day(lastRemindDate)*24+hour(lastRemindDate)+minute(lastRemindDate)/60)
列出区间内日期
SELECT TRUNC(TO_DATE(‘2014-01-01‘, ‘yyyy-MM-dd‘)) + ROWNUM - 1 AS DATES
FROM ALL_OBJECTS
WHERE TRUNC(TO_DATE(‘2014-01-01‘, ‘yyyy-mm-dd‘)) + ROWNUM - 1 <
TRUNC(TO_DATE(‘2020-01-01‘, ‘yyyy-mm-dd‘));
列出区间内月份
SELECT TO_CHAR(ADD_MONTHS(TO_DATE(‘2009-03‘,‘YYYY-MM‘),ROWNUM-1
),‘YYYY-MM‘) DAY_ID
FROM DUAL
CONNECT BY ROWNUM<=months_between
(to_date(‘2010-03‘, ‘yyyy-mm‘),to_date(‘2009-03‘, ‘yyyy-mm‘))+1
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。