declare cursor [del_cursor] is select a.*, a.rowid row_id from [table_name] a order by a.rowid; begin for v_cusor in [del_cursor] loop if v_cusor.[time_stamp] < to_date('2014-01-01','yyyy-mm-dd') then delete from [table_name] where rowid =…
DECLARE @tablename VARCHAR(30),@sql VARCHAR(500)DECLARE cur_delete_table CURSOR READ_ONLY FORWARD_ONLY FORSELECT name FROM sysobjects WHERE name LIKE 'PUB%' AND type='U'OPEN cur_delete_tableFETCH NEXT FROM cur_delete_table INTO @tablenameWHILE @@FETC…
在开发阶段往Oracle数据库中多个表格中导入了许多测试数据,倘若一张张表执行"truncate table tablename"语句显得十分繁琐.在PL/SQL中可以用代码进行批量删除表格数据.代码如下: declare cursor c_t is (select table_name from user_tables where table_name like 'D%');--声明一个游标 table_name user_tables.table_name%type;--声明一个表…