1. 设置一个私有的回滚段,可以设置大一些. SET TRANSACTION USE ROLLBACK SEGMENT RBSNAME; update TableName set ... COMMIT; 缺点:运行速度慢,并且会产生大量重做日志 2. 启动一个事务,批量更新 缺点: 速度不会快很多,但安全性有保证 3. 对表进行分区,然后在每个分区内执行更新操作(推荐) partition the data, do a parallel update. Each partition will use its own rollback segment, each will run in parallel.
设置条件 分批update 也可以阿 但是 就是速度不会很快 每一次还要检索 update a set aeg=18 where aeg=20 数据大了 本身就没有什么好方法 导入 导出 一次就要很长时间
If I had to update millions of records I would probably opt to NOT update.I would more likely do:CREATE TABLE new_table as select <do the update "here"> from old_table;index new_table grant on new table add constraints on new_table etc on new_tabledrop table old_table rename new_table to old_table; you can do that using parallel query, with nologging on most operations generating very little redo and no undo at all -- in a fraction of the time it would take to update the data.
也许可以试一下这个方法: loop update table set age=18 where age <> 18 and rownum < 100 ; commit; if sql%rowcount = 0 then break; end loop
to l2g32003(leeshow):It's a good idea! up 60多万条记录直接update也不会需要多少回滚段呀!!而且update占用回滚段又不多。 insert,update,delete占用回滚段大小是依次增加大的。 因为insert操作中回滚段中记录新记录的rowid,update时记录旧的更改过的字段值,而delete则不一样了,它要记录删除的记录的所有字段的信息。
方案一 1.create table test(c1,...,age,...,cn) nologging as select c1,...,18,...cn2.建立索引,主键3.删除原来的表(drop table)4.表改名(rename)方案二 1.删除索引再更新2.重建索引
速度上比较可行
把错误号码报出来大家看看,UPDATE命令本身无错!
1. 设置一个私有的回滚段,可以设置大一些.
SET TRANSACTION USE ROLLBACK SEGMENT RBSNAME;
update TableName set ...
COMMIT; 缺点:运行速度慢,并且会产生大量重做日志 2. 启动一个事务,批量更新 缺点: 速度不会快很多,但安全性有保证 3. 对表进行分区,然后在每个分区内执行更新操作(推荐) partition the data, do a parallel update. Each partition
will use its own rollback segment, each will run in parallel.
update a set aeg=18 where aeg=20 数据大了 本身就没有什么好方法 导入 导出 一次就要很长时间
grant on new table
add constraints on new_table
etc on new_tabledrop table old_table
rename new_table to old_table;
you can do that using parallel query, with nologging on most operations
generating very little redo and no undo at all -- in a fraction of the time it
would take to update the data.
loop
update table
set age=18
where age <> 18
and rownum < 100
;
commit;
if sql%rowcount = 0 then break;
end loop
whan1234(小韩) 的方法就是批量更新.
如果让我选择,我会考虑 l2g32003的方法.
up
60多万条记录直接update也不会需要多少回滚段呀!!而且update占用回滚段又不多。
insert,update,delete占用回滚段大小是依次增加大的。
因为insert操作中回滚段中记录新记录的rowid,update时记录旧的更改过的字段值,而delete则不一样了,它要记录删除的记录的所有字段的信息。
1.create table test(c1,...,age,...,cn) nologging
as
select c1,...,18,...cn2.建立索引,主键3.删除原来的表(drop table)4.表改名(rename)方案二
1.删除索引再更新2.重建索引