create or replace procedure ymq_test is temptablenames varchar2(100); cursor c_emp is select table_name from sys.dba_tables where tablespace_name='MOF' and table_name like 'TMP%' and owner='YMQ'; begin open c_emp; loop fetch c_emp into temptablesname; exit when c_emp%notfound; execute immediate 'drop'11temptablename''; end loop; close c_emp; end;编译错误 pl/sql:ora-00942:表或视图不存在。其中11代表双竖线,那个键坏了所以用11来代替。
然后在windows 里做个计划任务每到周五的0:30就调用这个过程
temptablenames varchar2(100);
cursor c_emp is
select table_name
from sys.dba_tables
where tablespace_name='MOF'
and table_name like 'TMP%'
and owner='YMQ';
begin
open c_emp;
loop
fetch c_emp
into temptablesname;
exit when c_emp%notfound;
execute immediate 'drop'11temptablename'';
end loop;
close c_emp;
end;编译错误 pl/sql:ora-00942:表或视图不存在。其中11代表双竖线,那个键坏了所以用11来代替。
另外dba_tables也没必要加sys.'drop'11temptablename'' 缺少table关键字。
可以通过dbms_job包调用这个procedure,来实现自动执行。