=> object 생성, Data 생성, 통계정보수집
drop table t1 purge;
create table t1(c1 int, c2 int);
insert into t1
select mod(level,100), level
from dual
connect by level <= 100;
commit;
exec dbms_stats.gather_table_stats ('HYUN','t1',CASCADE=>TRUE,method_opt =>'FOR COLUMNS c1 SIZE 254');
select * from table(dbms_stats.diff_table_stats_in_stattab('HYUN','t1','t1_stat'));
=> 현재 통계정보를 EXPORT 한다
exec dbms_stats.create_stat_table('HYUN','t1_stat');
exec dbms_stats.export_table_stats('HYUN','t1',null,'t1_stat');
=> Data의 분포를 크게 변경한 후 통계정보를 수집한다.
insert into t1
select mod(level,2), level
from dual
connect by level <= 10000;
commit;
exec dbms_stats.gather_table_stats ('HYUN','t1',CASCADE=>TRUE,method_opt =>'FOR COLUMNS c1 SIZE 254');
select * from table(dbms_stats.diff_table_stats_in_stattab('HYUN','t1','t1_stat'));
dbms_stats.create_stat_table('owner', '테이블명','테이블스페이스명');
ex) exec dbms_stats.create_stat_table('HYUN', 'T1', 'HYUN');
dbms_stats.export_schema_stats ('schema name', 'stat table','stat_id','stat table owner');
dbms_stats.export_table_stats ('table_owner', 'table name', null, 'stat table','stat_id',true,'stat table owner');
ex) exec dbms_stats.export_table_stats ('hyun', 't1', null, 'stat_tab','0414',true,'hyun');
Statid 는 restore 시 통계정보 버전별 식별자 역할을 함.
dbms_stats.import_table_stats ('table_owner', 'table name', null, 'stat table','stat_id',true,'stat table owner');
ex) exec dbms_stats.import_table_stats ('inv', 'mtl_system_items_b', null, 'stat_tab','0414',true,'apps');
-- 통계정보수집테이블생성
BEGIN dbms_stats.create_stat_table('hyun', 'TB_STAT_ANAL','ts_d01');
END;
/
=> object 생성, Data 생성, 통계정보수집
drop table t1 purge;
create table t1(c1 int, c2 int);
insert into t1
select mod(level,100), level
from dual
connect by level <= 100;
commit;
exec dbms_stats.gather_table_stats ('HYUN','t1',CASCADE=>TRUE,method_opt =>'FOR COLUMNS c1 SIZE 254');
=> 통계정보 확인 (약식)
select table_name,num_rows
from tabs
where table_name = 'T1';
TABLE_NAME NUM_ROWS
------------------------------ ----------
T1 100
=> 현재 통계정보를 EXPORT 한다
BEGIN dbms_stats.export_schema_stats ('HYUN', 'TB_STAT_ANAL','V1','HYUN');
END;
/
=> Data의 분포를 크게 변경한 후 통계정보를 수집한다.
insert into t1
select mod(level,2), level
from dual
connect by level <= 10000;
commit;
exec dbms_stats.gather_table_stats ('HYUN','t1',CASCADE=>TRUE,method_opt =>'FOR COLUMNS c1 SIZE 254');
=> 통계정보 확인 (약식)
select table_name,num_rows
from tabs
where table_name = 'T1';
TABLE_NAME NUM_ROWS
------------------------------ ----------
T1 10100
=> 예전통계정보 복구
exec dbms_stats.import_table_stats ('hyun', 't1', null, 'TB_STAT_ANAL','V1',true,'hyun');
=> 확인
TABLE_NAME NUM_ROWS
------------------------------ ----------
T1 100
- 강좌 URL : http://www.gurubee.net/lecture/3972
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.