日期:2014-05-16  浏览次数:20611 次

清空当前用户所有表数据存储过程
declare
  v_sqlD varchar2(2000);
  v_sql varchar2(2000);
  CURSOR curD is
    select table_name,constraint_name from USER_CONSTRAINTS where constraint_type='R' order by table_name;
  CURSOR cur is
    select table_name from user_tables order by table_name;
begin
  for rowsD in curD loop
    v_sqlD := 'ALTER TABLE ' || rowsD.table_name || ' disable constraint ' || rowsD.constraint_name;
    dbms_output.put_line(v_sqlD);
     execute immediate v_sqlD;
  end loop;
  for rows in cur loop
    v_sql := 'TRUNCATE TABLE ' || rows.table_name;
    dbms_output.put_line(v_sql);
    execute immediate v_sql;
  end loop;
end;
/