NOLOGGING无效

时间:2015-06-27 10:01:53

标签: mysql sql oracle

这是我的代码的一部分。一切都好,没有错误。但我要插入数百万行。我在互联网上搜索了更快完成工作的方法。

我发现,是使用nologgin和+ append在表中插入,但是不起作用。

表示在表中插入相同行的时间是相同的,即使我使用nologging和追加。

    create or replace procedure read_files(input varchar2, extensie varchar2) as  
........................................ 
    Loop
     BEGIN
..............................
        UTL_FILE.GET_line(F1,V1);
    insert /*+ append */ into alarms(alarm_id,property_name,property_value) 
    =values(alarm_counter,f_property_name,f_property_value) ;

     End loop;
    end; 


alter table alarms nologging;
execute read_files('occ','cap');
alter table alarms logging;

我的工作步骤:

  • 首先编译程序
  • alter table nologging
  • 执行程序

我的错误在哪里?

1 个答案:

答案 0 :(得分:1)

APPEND提示仅适用于INSERT .. SELECT语句。 APPEND_VALUES提示  用于INSERT .. VALUES语句。

直接路径插入有几个要求和限制。在尝试APPEND_VALUES提示之前,尝试FORALL会更好。它增加了额外的步骤,但它减少了SQL和PL / SQL之间的上下文切换,这可以显着提高性能。

declare
    type alarm_counter_nt is table of number;
    type f_property_name_nt is table of varchar2(100);
    type f_property_value_nt is table of varchar2(100);
    alarm_counters alarm_counter_nt := alarm_counter_nt();
    property_names f_property_name_nt := f_property_name_nt();
    property_values f_property_value_nt := f_property_value_nt();
begin
    --Get values.
    loop
        utl_file_get_line(f1, v1);
        alarm_counters.extend;
        alarm_counters(alarm_counters.count) := ?;
        f_property_names.extend;
        f_proprety_names(f_property_names.count) := ?;
        f_property_values.extend;
        f_property_values(f_property_values.count) := ?;
    end loop;

    --Insert values.
    forall i in 1 .. alarm_counters.count
        insert into alarms(alarm_id,property_name,property_value) 
        values(alarm_counters(i),f_property_names(i),f_property_values(i)) ;

    commit;
end;
/