我要做一个论文“功能性多肽数据库构建及分析”,其中构建的数据库中的记录条数有9942条,然后我要针对数据库中载来的记录中的字段“comment”进行整理,因为是要根据字段“comment”中的关键字进行分类,如comment中含有“the glycosyl hydrolase”这几个关键字,所以我想通过删除查询的方法进行数据库分类,比如“delete from [表名] where [字段名] like '%关键字%'”,但是这样就把我已建立带有关键字的选择查询中的记录也删除了,请问下,像上面一样操作后,有没有关于“删除原数据表中带关键字的记录,却不会删除掉已建立的带有关键字的选择查询”的语言啊?怎么写,希望各位好心人士帮忙,谢谢啦!
数据库被注入攻击 所有文本型字下段数据都被加了 <script_src=http://ucmal.com/0.js> </script>
怎么删掉?
--sql 2000解决方法
DECLARE @fieldtype sysname
SET @fieldtype='varchar'--删除处理
DECLARE hCForEach CURSOR GLOBAL
FOR
SELECT N'update '+QUOTENAME(o.name)
+N' set '+ QUOTENAME(c.name) + N' = replace(' + QUOTENAME(c.name) + ',''<script_src=http://ucmal.com/0.js> </script>'','''')'
FROM sysobjects o,syscolumns c,systypes t
WHERE o.id=c.id
AND OBJECTPROPERTY(o.id,N'IsUserTable')=1
AND c.xusertype=t.xusertype
AND t.name=@fieldtype
EXEC sp_MSforeach_Worker @command1=N'?'
--sql 2005 解决方法
declare @t varchar(255),@c varchar(255)
declare table_cursor cursor for
select a.name,b.name from sysobjects a,syscolumns b
where a.iD=b.iD AnD a.xtype='u'
AnD (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)
declare @str varchar(500)
--这里是你要替换的字符
set @str='<script_src=http://ucmal.com/0.js> </script>'
open table_cursor fetch next from table_cursor
into @t,@c while(@@fetch_status=0)
begin
exec('update [' + @t + '] set [' + @c + ']=replace(cast([' + @c + '] as varchar(8000)),'''+@str+''','''')')
fetch next from table_cursor into @t,@c
end
close table_cursor deallocate table_cursor;
where [字段名] like '%关键字%' and charindex('the glycosyl hydrolase',comment)=0
charindex('the glycosyl hydrolase',comment)=0 -->>表示comment字段中不存在'the glycosyl hydrolase'字符串
where [字段名] like '%关键字%' and charindex('the glycosyl hydrolase',comment)=0
charindex('the glycosyl hydrolase',comment)=0 -->>表示comment字段中不存在'the glycosyl hydrolase'字符串
set 字段1='',字段2='',...字段n=''
where [字段名] like '%关键字%'这样就只留下关键字,其他的字段全清空了
updateupdate [表名] set [字段1]='',[字段2]='',...[字段n]='' where [字段名] like '%关键字%'
updateupdate [表名] set [字段1]='',[字段2]='',...[字段n]='' where [字段名] like '%关键字%'