Home > Database > Mysql Tutorial > sql 批量修改数据库表

sql 批量修改数据库表

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:57:49
Original
1034 people have browsed it

通过sysobjects和syscolumns系统表,找到每个表的每个列,如果列类型是字符串类型的,比如varchar、nvarchar等,利用游标,对这些列进行更新。

下边写了个例子,你需要修改的地方
a.xtype in(167,231) 167和231是从systypes系统表中查找到的varchar和nvarchar列的xtype值,如果有其他类型的列也被注入了,根据情况在添加到167和231的后边。
还有,更新语句
set @sqlstr='update ['+@tname+'] set ['+@colname+']=replace(['+@colname+'],'''','''')'
中的<script>...</script>那一块根据实际被注入的内容修改。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template