删除所有表

来源:互联网 发布:oracle数据库建表 编辑:程序博客网 时间:2024/05/29 11:27

--删除表结构

declare  

  cursor c_t is (select table_name from user_tables);--声明一个游标  
  table_name user_tables.table_name%type;--声明一个表名的变量  
begin   
  open c_t;  
  loop--循环  
       fetch c_t into table_name;  
       exit when c_t%notfound;  
       execute immediate 'drop  table ' || table_name;--动态sql删除  
  end loop;  
  close c_t;  

end;  


--清空表

  1. declare  
  2.   cursor c_t is (select table_name from user_tables);--声明一个游标  
  3.   table_name user_tables.table_name%type;--声明一个表名的变量  
  4. begin   
  5.   open c_t;  
  6.   loop—循环  
  7.        fetch c_t into table_name;  
  8.        exit when c_t%notfound;  
  9.        execute immediate 'delete from ' || table_name;--动态sql删除  
  10.   end loop;  
  11.   close c_t;  
  12. end;

0 0