alter table table_name cache,将表中的记当放到数据缓存的末端,从而减少的磁盘输入输出
在非归档模式下通过insert /*+ append */ into方式批量加载数据可以大大减少redo产生.
可以看到在归档模式下,且表的logging属性为true,insert /*+ append */ into这种方式也会纪录大量redo
在归档模式下,要设置表的logging属性为false,
才能通过insert /*+ append */ into大大减少redo.
们看到对于批量操作,如果设置表nologging,可以大大提高性能.原因就是Oracle没有纪录DML所产生的redo.
当然,这样会影响到备份。nologging加载数据后要做数据库全备.
alter table fact_ccs_tbilllog parallel degree 35
select /*+full(t) parallel(t,35)*/
from fact_ccs_tbilllog ;
analyze table lxy_4 compute statistics
declare
type my is table of number(6) index by binary_integer;
type my2 is table of varchar2(10) index by binary_integer ;
va1 my;
va2 my2;
--va1 number(6);
--va2 varchar2(10);
start_time number(10);
end_time number(10);
begin
for i in 1 .. 10 loop
va1(i) := i;
va2(i) := 'name' || to_char(i);
end loop;
start_time := dbms_utility.get_time;
for i in 1 .. va1.count loop
insert into lxy_t3 values (va1(i), va2(i));
end loop;
commit;
end_time := dbms_utility.get_time;
dbms_output.put_line((end_time - start_time) / 100);
end;
select * from dba_tab_columns;
我们可能使用两种主法将ORACLE表中记当按主键顺序重新排序
1 索引簇
2 手工重新(CTAS):create table table_name as select ...
A: order by (parallel(degree 35))
B: /*+index (t,index_name)*/
注意:如果想要对表进行flashback,必须允许表的row movement.
Alter table table_name row movement;
SELECT ROW_MOVEMENT FROM USER_TABLES WHERE TABLE_NAME='LXY_4';
ALTER TABLE table_name ENABLE ROW MOVEMENT;
关于cursor循环,有两种方式:
1. 使用loop, exit (不用while)
如:
loop
fetch emp_cur into v_emp;
exit when emp_cur%notfound;
dbms_output.put_line(v_emp.ename);
end loop;
2. 使用while, 这时先要fetch
fetch emp_cur into v_emp;
while (emp_cur%found)
loop
dbms_output.put_line(v_emp.ename);
fetch emp_cur into v_emp;
end loop;
declare
begin_date date := to_date('20100701', 'yyyymmdd');
end_date date := to_date('20100901', 'yyyymmdd');
begin
while begin_date < end_date loop
insert into rpt_d0072
select /*+ indexl(t2,IDX_TT_WAYBILL_3)*/
bill_no, t2.addressee_addr_native, send_time
from smsrun.MessageTo_bak t1, tt_waybill t2
where input_tm >= begin_date
and input_tm < begin_date + 1
and t1.bill_no = t2.waybill_no
and t2.input_type_code = '1';
begin_date := begin_date + 1;
end loop;
end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12122734/viewspace-675166/ ,如需转载,请注明出处,否则将追究法律责任。