美股历史行情:sql中删除所有php开头的表,如何操作?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/04 14:56:21
sql中删除所有php开头的表,如何操作?
我用phpmyadmin,如何把mysql 里面php打头的表都删了呢?

呵呵,mysql呀?不说清楚点……不过我不知道mysql中系统表信息存储在哪里。反正解决方法是类似的。

用游标从系统表中找到所有php开头的表名,然后用动态语句drop掉就可以了,如下

declare @sqlstr varchar(1000)
declare @TableName varchar(100)

declare curGetTable cursor for
select name
from sysobjects
where type='u' and name like 'php%'

open curGetTable

fetch next from curGetTable
into @Tablename

while @@fetch_status=0
begin
set @sqlstr='drop table '+@TableName
exec(@sqlstr)
fetch next from curGetTable
into @Tablename
end

close curGetTable
deallocate curGetTable

在程序里写吧

楼上的能解释一下各语句的功能吗?