我只能给出Oracle的一个示例:declare cursor get_table is select tname from tab where tname not in('TABLE1',TABLE2','TABLE3','TABLE4'); begin for temp_cursor in get_table loop delete from temp_cursor.tname; (or:truncate table temp_cursor.tname;) end loop; end;
利用sysobjects表,实现这个功能很简单。
create procedure DropTable as declare @TableName varchar(100), @SQL nvarchar(100) declare curGetTable cursor for select name from sysobjects where type='u' open curGetTable fetch next from curGetTable into @TableName while @@fetch_status=0 begin if @TableName not in('aaa','bbb','pic2db') begin set @SQL='drop table '+@TableName --print @sql execute sp_executesql @SQL end fetch next from curGetTable into @TableName end close curGetTable deallocate curGetTable========================== 以上代码在SQL SERVER 7.0通过
cursor get_table is
select tname from tab
where tname not in('TABLE1',TABLE2','TABLE3','TABLE4');
begin
for temp_cursor in get_table loop
delete from temp_cursor.tname;
(or:truncate table temp_cursor.tname;)
end loop;
end;
declare @TableName varchar(100),
@SQL nvarchar(100)
declare curGetTable cursor for
select name from sysobjects where type='u'
open curGetTable
fetch next from curGetTable into @TableName
while @@fetch_status=0
begin
if @TableName not in('aaa','bbb','pic2db')
begin
set @SQL='drop table '+@TableName
--print @sql
execute sp_executesql @SQL
end
fetch next from curGetTable into @TableName
end
close curGetTable
deallocate curGetTable==========================
以上代码在SQL SERVER 7.0通过