這裡蒐索程式師資訊,查找有用的技術資料
当前位置:首页 » 服务存储 » 存储过程批量改字段
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

存储过程批量改字段

发布时间: 2022-09-26 13:54:19

‘壹’ oracle 存储过程批量修改字段内容

可以用java程序来做 即把数据库中的所有的数据 一条一条地封装成类 然后放在一个List集合中 然后把这个List作为参数 在一个方法里对这个List存储的对象进行提取 和修改 然后再通过修改后的对象数据的数据进行修改

‘贰’ mybatis 调用存储过程进行批量修改操作(只需要一次调用存储过程),不知道如何配置配置文件

public class test
{
public static void main(String[] args)
{
Circle C=new Circle(4);
Rectangles Rt=new Rectangles(4, 4);
Triangle T=new Triangle(6,7);
C.Area();
Rt.Area();
T.Area();
}
}

‘叁’ sql语句 怎么批量修改A表中B字段的值

你认为的没有错,但是如果你这样修改之后,你那个程序/系统/网站估计登陆就有问题了。
最保险的办法是你新注册一个账户,密码设置成1,然后到数据库里查询这条
记录,把他的密码记录下来。
然后用SQL
update
A
set
B='刚刚你记录下来的那一个加密串',更新数据库,这样所有的密码就都被你改成1了。

‘肆’ SQLServer如何根据a表ID批量更改b表字段名为a表name

1、通过存储过程
2、游标获取要更新的a表的集合
3、循环遍历a表的记录
4、获取到a表的记录后,第一条记录更新b的第一个字段,第二条记录更新b的第二个字段 依次处理即可

‘伍’ sql语句 怎么批量修改A表中B字段的值

Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from [表1] A left join [表2] B on A.MB001=B.MB001 where B.MB002=1"
rs.open sql,conn,1,3
Do While not rs.eof
RS("A.MB002")=201
rs.update
rs.MoveNext
loop
rs.close
Set rs=Nothing
假定数据都是数字类型如果是char类型修改相关地方!

‘陆’ sql批量修改字段

通过存储过程来实现,方法说明:
1、建一个临时表用于存放表名和字段名;
2、在系统表中查看有该字段的所有表,存入临时表
3、在临时表建游标,逐条执行修改;
4、删除临时表。

CREATE PROCEDURE Rename
@databaseName varchar(500),
@oldName varchar(500),
@newName varchar(500)
AS
create table #temp(tablename varchar(200),columnName varchar(200))
declare @tableName_cursor varchar(200)
declare @colName_cursor varchar(200)
declare @objName varchar(200)
declare @tableName varchar(200),@colName varchar(200)
exec('declare tableName_cursor cursor for select name from '+@databaseName+'.dbo.sysobjects where xtype=''u'' and status >= 0')
open tableName_cursor
fetch next from tableName_cursor into @tableName_cursor
while @@fetch_status = 0
begin
insert into #temp select @tableName_cursor,name from syscolumns where id = object_id(@tableName_cursor)
fetch next from tableName_cursor into @tableName_cursor
end
close tableName_cursor
deallocate tableName_cursor

declare col_cursor cursor for select columnName from #temp
open col_cursor
fetch next from col_cursor into @colName_cursor
while @@fetch_status = 0
begin
if @colName_cursor = @oldName
begin
select @tableName=tableName,@colName=columnName from #temp where columnName = @colName_cursor
set @objName = @tableName+'.'+@colName
exec sp_rename @objName,@newName,'Column'
end
fetch next from col_cursor into @colName_cursor
end
close col_cursor
deallocate col_cursor

select * from #temp where columnName = 'isdeleted' or columnName = 'isdatadeleted'
drop table #temp
GO

exec rename @databaseName='test',@oldName='isdeleted',@newName = 'isdatadeleted'

drop PROCEDURE rename

‘柒’ 帮忙写一个存储过程。批量更新表中的某一个INT类型的字段,使他的值乘以0.05

create procere 存储过程名
as
update 表名 set 字段名=字段名*0.05
--存储过程完鸟
-----------------------------------------------------------
友情提醒:
SQL Server2005有时这样乘会出问题(结果不对之类),不知道什么原因。所以我一般会强制转换一次,然后用round规定一下保留位数。所以update语句改成:update 表名 set 字段名=round(convert(float,字段名)*0.05 ,6)
P.S. 偶是mm,强烈感觉楼主对IT女深深的歧视