[oracle@redhat errormsg]$ touch test01.txt
(2)在数据库中创建路径及授权
(3)创建存储过程
CREATE OR REPLACE PROCEDURE export_test01 IS export_handle UTL_FILE.file_type; BEGIN export_handle := UTL_FILE.FOPEN('LIJIAMAN_DIR',test01.txtw'); FOR x IN (SELECT * FROM lijiaman.test01) LOOP UTL_FILE.PUT_LINE(export_handle,x.id || ,' || x.name); END LOOP; UTL_FILE.FCLOSE(export_handle); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SUBSTR(sqlERRM,1,2000)); END;
(4)创建job,1分钟跑一次
declare
job1 number;
begin
sys.dbms_job.submit(job1,1)">export_test01;=> sysdate,interval =>sysdate + 1/1440);
end;
(5)观察job情况
sql> select from user_jobs; JOB LOG_USER PRIV_USER SCHEMA_USER LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE NEXT_SEC TOTAL_TIME BROKEN INTERVAL FAILURES WHAT ---------- ----------- ----------- ------------- ----------- -------- ----------- -------- ----------- -------- ---------- ------ ------------------ ---------- ----------------- 4 LIJIAMAN LIJIAMAN LIJIAMAN 2017/1122 23:24:32 25:32 0 N sysdate + 11440 0 export_test01;