1.定时任务的创建
declare
x varchar2(20);
BEGIN
DBMS_JOB.SUBMIT(
JOB => x, /*自动生成JOB_ID*/
WHAT => 'DECLARE VAR_APPCODE VARCHAR2(200); VAR_ERRORMSG VARCHAR2(200);
BEGIN
PKG_DATASYNC.PRC_DATASYNC_CONTROL(VAR_APPCODE,VAR_ERRORMSG);
END;', /*需要执行的存储过程名称或SQL语句*/
NEXT_DATE => sysdate, /*初次执行时间-立即执行*/
INTERVAL => 'TRUNC(sysdate+ 1)+15/(48)' /*每隔1分钟执行一次*/
);
commit;
end;
备注:当INTERVAL 参数传入空值时,默认执行一次就完了。
2.终止正在运行的定时任务
begin
dbms_job.broken(79,true);
commit;
end;
3.删除掉定时任务
begin
dbms_job.remove(79); commit;
end;
4.修改定时任务的下次执行时间
begin
dbms_job.next_date(87,to_date('2021-08-30 03:00:02','yyyy-mm-dd hh24:mi:ss'));
commit;
end;
5.查询和删除会话
select USERNAME, SID, SERIAL#, STATUS, osuser,MACHINE,PROGRAM,MODULE,ACTION,LOGON_TIME,SADDR,AUDSID,PADDR,USER#,COMMAND,OWNERID
from v$session
where username is not null
and status = 'ACTIVE' and username='xxxxxxxx'
order by logon_time, sid;
alter system kill session '2720,15803' immediate;
6.sysdba用户授权创建DBLINK
grant create DATABASE LINK to sc_510100;
7.创建DBLINK
create database dblinkNAME
connect to username identified by password
using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = 172.18.132.136)(PORT = 9000)))(CONNECT_DATA =(SERVICE_NAME = HMHN)))';
8.删除dblink
drop database link dblinkname ;
9.查看DBlink
select * from dba_db_links;