insert into table a select * from table b 大数据量怎么办

huangdh12 2010-08-01 10:50:06
insert into table a select * from table b ;
量表结构一样,b表大概2千万条,
这一次性插入大概要20分钟左右,同时这个事物也非常大。有没有办法让 这语句每1万条提交一次?
...全文
2414 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
minitoy 2010-08-02
  • 打赏
  • 举报
回复
hints append,直接使用hwm以上的数据块,以提高处理效率。
parallel并行,
nologging不记日志
huangdh12 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 wkc168 的回复:]

引用楼主 huangdh12 的回复:
insert into table a select * from table b ;
量表结构一样,b表大概2千万条,
这一次性插入大概要20分钟左右,同时这个事物也非常大。有没有办法让 这语句每1万条提交一次?

SQL code

insert /*+append*/ into a select * from b
[/Quote]

这句没看懂
minitoy 2010-08-02
  • 打赏
  • 举报
回复
parallel,append,nologging都加上
心中的彩虹 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用楼主 huangdh12 的回复:]
insert into table a select * from table b ;
量表结构一样,b表大概2千万条,
这一次性插入大概要20分钟左右,同时这个事物也非常大。有没有办法让 这语句每1万条提交一次?
[/Quote]

insert /*+append*/ into a select * from b
shjp123 2010-08-02
  • 打赏
  • 举报
回复
parallel,append,nologging都加上.再加上分区试一下。
心中的彩虹 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 wkc168 的回复:]
引用楼主 huangdh12 的回复:
insert into table a select * from table b ;
量表结构一样,b表大概2千万条,
这一次性插入大概要20分钟左右,同时这个事物也非常大。有没有办法让 这语句每1万条提交一次?


SQL code

insert /*+append*/ into a select * from b
[/Quote]
忘了 弄完就的commit
lzbbob1985 2010-08-01
  • 打赏
  • 举报
回复
那把并行 和 append 加上 看看
huangdh12 2010-08-01
  • 打赏
  • 举报
回复
没有分区。。。
你下面写的语句是根据分区来的吗?
我的处理方式是 用查询条件将表分成了129个表,然后挨个insert into table as select * from b_i;
方法虽然笨了点,好歹可行。。:)
orbcle 2010-08-01
  • 打赏
  • 举报
回复
create or replace procedure bulk_insert(in_bulk_count integer)
is
cursor cur is select * from b;
type tbl_b is table of b%rowtype index by pls_integer;
v_tbl_b tbl_b;
begin
open cur;
loop
<<bulk_insert>>
exit when cur%notfound;
fetch cur bulk collect into v_tbl_b limit in_bulk_count;
forall i in indices of v_tbl_b save exceptions
insert /*+append*/ into a values v_tbl_b(i);
commit;
exception
when others then
null;
end loop bulk_insert;
close cur;
end;
lzbbob1985 2010-08-01
  • 打赏
  • 举报
回复
b 表有 分区吗?
有分区的话 用分区

可以添加并行处理

insert into table a

select /*+parallel(b,6)*/
/*+append*/
*
from table partition(part....) b ; --parallel(b,6) 后面的 6为并行处理的数量 通常和CPU 数量相同
huangdh12 2010-08-01
  • 打赏
  • 举报
回复
plsql 那不是要循环 2千万次? 那不废了?

根据条件倒是也可以。。只是我想有没有什么设置,不用去写plsql语句了。
lacus87 2010-08-01
  • 打赏
  • 举报
回复
PL_SQL做吧,SQL语言貌似不行。。。

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧