Oracle统计时用全局临时表 新建Oracle作业
Oracle统计时用全局临时表 新建Oracle作业
1.新建Oracle全局临时表,代码如下:Sql代码
- DECLARE cnt int;
- begin
- --如果存在该临时表,则删除
- SELECT count(1) into cnt from user_tables where table_name='TEMPLOGSMSHALL_SESSION';
- if cnt>0 THEN
- BEGIN
- execute immediate 'DROP TABLE TEMPLOGSMSHALL_SESSION';
- END;
- end if;
- end;
- /
- --创建临时表
- CREATE GLOBAL TEMPORARY TABLE TempLogSmsHall_Session (
- SESSIONID VARCHAR2(28) NOT NULL,
- USERTELNO VARCHAR2(16) NOT NULL,
- USERCITYNAME VARCHAR2(8) NOT NULL,
- USERBRANDNAME VARCHAR2(16) NOT NULL,
- NLIBIZNAME VARCHAR2(32) NOT NULL,
- BIZNAME VARCHAR2(128) NOT NULL,
- OPERATIONNAME VARCHAR2(16) NOT NULL,
- SCENEHANDLETYPE VARCHAR2(32) NOT NULL,
- SCENEHANDLEID VARCHAR2(6) NOT NULL,
- SESSIONBEGINTIME TIMESTAMP NOT NULL,
- SESSIONENDTIME TIMESTAMP NOT NULL,
- ISTIMEOUT CHAR(1) DEFAULT '1' NOT NULL,
- ALLCOSTSECONDS INTEGER DEFAULT (0) NOT NULL,
- REVSMSNUM INTEGER DEFAULT (0) NOT NULL,
- SENDSMSNUM INTEGER DEFAULT (0) NOT NULL
- )
- ON COMMIT PRESERVE ROWS;
2.新建Oracle作业,代码如下:
Sql代码
- DECLARE job NUMBER;
- begin
- dbms_job.submit(job => job,
- what => 'ECSS_JOB.SMSS10_Job_DailyStatus('''');',
- next_date => trunc(sysdate) + ( 1 + 1/24),
- interval => 'sysdate + 1');
- commit;
- end;
1/24 一小时;
1/1440 一分;
1/3600 一秒;
另外,注意SQL不要执行多次,执行了几次就会提交几个作业
评论暂时关闭