Bo's Oracle Station

查看: 1445|回复: 0

第57-58次:2015-05-30星期六上下午

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2015-5-29 09:43:14 | 显示全部楼层 |阅读模式
本帖最后由 botang 于 2015-6-1 16:05 编辑
  1. select  * from v$database_block_corruption;

  2. select  * from v$backup_corruption;

  3. select  * from v$copy_corruption;

  4. select  * from dba_tablespaces;

  5. BEGIN
  6. DBMS_REPAIR.ADMIN_TABLES (
  7.    table_name => 'REPAIR_TABLE',
  8.    table_type => DBMS_REPAIR.REPAIR_TABLE,
  9.    action => DBMS_REPAIR.CREATE_ACTION,
  10.    tablespace => 'USERS');
  11. END;

  12. select  * from  REPAIR_TABLE;

  13. BEGIN
  14. DBMS_REPAIR.ADMIN_TABLES (
  15.    table_name => 'ORPHAN_KEY_TABLE',
  16.    table_type => DBMS_REPAIR.ORPHAN_TABLE,
  17.    action => DBMS_REPAIR.CREATE_ACTION,
  18.    tablespace => 'USERS');
  19. END;

  20. select  * from ORPHAN_KEY_TABLE;


  21. DECLARE
  22.   num_corrupt INT;
  23. BEGIN
  24. num_corrupt := 0;
  25. DBMS_REPAIR.CHECK_OBJECT (
  26.    schema_name => 'HR',
  27.            object_name => 'TLOGICAL',
  28.    repair_table_name => 'REPAIR_TABLE',
  29.    corrupt_count => num_corrupt);
  30.   dbms_output.put_line( 'Find  '|| num_corrupt||' Bolcks.'  );
  31. END;

  32. DECLARE
  33. num_fix INT;
  34. BEGIN
  35. num_fix := 0;
  36. DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
  37.            schema_name => 'HR',
  38.            object_name => 'TLOGICAL',
  39.            object_type => DBMS_REPAIR.TABLE_OBJECT,
  40.            repair_table_name => 'REPAIR_TABLE',
  41.    fix_count => num_fix   );
  42.    dbms_output.put_line( 'Fixed  '|| num_fix||' Bolcks.'  );
  43. END;

  44. select  * from dba_indexes i where table_name='TLOGICAL';

  45. select  * from ORPHAN_KEY_TABLE;


  46. DECLARE
  47. num_orphans INT;
  48. BEGIN
  49. num_orphans := 0;
  50. DBMS_REPAIR.DUMP_ORPHAN_KEYS (
  51.   schema_name => 'HR',
  52.   object_name => 'ILOGICAL_B',
  53.   object_type => DBMS_REPAIR.INDEX_OBJECT,
  54.   repair_table_name => 'REPAIR_TABLE',
  55.   orphan_table_name => 'ORPHAN_KEY_TABLE',
  56.   key_count => num_orphans);
  57. DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
  58. END;

  59. select  * from ORPHAN_KEY_TABLE  where index_name='ILOGICAL_B'   and keyrowid||' '='AAASOAAIgAAAAACAAA'||' ' ;


  60. select  * from v$database_block_corruption;

  61. select  * from v$backup_corruption;

  62. select  * from v$copy_corruption;

  63. select  * from dba_tablespaces;

  64. BEGIN
  65. DBMS_REPAIR.ADMIN_TABLES (
  66.    table_name => 'REPAIR_TABLE',
  67.    table_type => DBMS_REPAIR.REPAIR_TABLE,
  68.    action => DBMS_REPAIR.CREATE_ACTION,
  69.    tablespace => 'USERS');
  70. END;

  71. select  * from  REPAIR_TABLE;

  72. BEGIN
  73. DBMS_REPAIR.ADMIN_TABLES (
  74.    table_name => 'ORPHAN_KEY_TABLE',
  75.    table_type => DBMS_REPAIR.ORPHAN_TABLE,
  76.    action => DBMS_REPAIR.CREATE_ACTION,
  77.    tablespace => 'USERS');
  78. END;

  79. select  * from ORPHAN_KEY_TABLE;


  80. DECLARE
  81.   num_corrupt INT;
  82. BEGIN
  83. num_corrupt := 0;
  84. DBMS_REPAIR.CHECK_OBJECT (
  85.    schema_name => 'HR',
  86.            object_name => 'TLOGICAL',
  87.    repair_table_name => 'REPAIR_TABLE',
  88.    corrupt_count => num_corrupt);
  89.   dbms_output.put_line( 'Find  '|| num_corrupt||' Bolcks.'  );
  90. END;

  91. DECLARE
  92. num_fix INT;
  93. BEGIN
  94. num_fix := 0;
  95. DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
  96.            schema_name => 'HR',
  97.            object_name => 'TLOGICAL',
  98.            object_type => DBMS_REPAIR.TABLE_OBJECT,
  99.            repair_table_name => 'REPAIR_TABLE',
  100.    fix_count => num_fix   );
  101.    dbms_output.put_line( 'Fixed  '|| num_fix||' Bolcks.'  );
  102. END;

  103. select  * from dba_indexes i where table_name='TLOGICAL';

  104. select  * from ORPHAN_KEY_TABLE;


  105. DECLARE
  106. num_orphans INT;
  107. BEGIN
  108. num_orphans := 0;
  109. DBMS_REPAIR.DUMP_ORPHAN_KEYS (
  110.   schema_name => 'HR',
  111.   object_name => 'ILOGICAL_B',
  112.   object_type => DBMS_REPAIR.INDEX_OBJECT,
  113.   repair_table_name => 'REPAIR_TABLE',
  114.   orphan_table_name => 'ORPHAN_KEY_TABLE',
  115.   key_count => num_orphans);
  116. DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
  117. END;

  118. select  * from ORPHAN_KEY_TABLE  where index_name='ILOGICAL_B'   and keyrowid||' '='AAASOAAIgAAAAACAAA'||' ' ;

  119. alter tablespace tbsa offline immediate;


  120. begin
  121.    dbms_repair.skip_corrupt_blocks('HR','TLOGICAL');
  122. end;


  123. select  dump(key)   from  ORPHAN_KEY_TABLE  where index_name='ILOGICAL_A'   and keyrowid||' '='AAASOAAIgAAAAACAAA'||' ' ;

  124. 195,3,33,56

  125. select  * from v$diag_info;

  126. select  * from V$HM_CHECK  where  name  like   '%Matadata%';

  127. select  * from  V$HM_CHECK_PARAM where id=24 ;

  128. select  * from v$hm_run;

  129. begin
  130. dbms_hm.run_check('Dictionary Integrity Check',
  131.                                             'mycheck',0,'TABLE_NAME=tab





  132. migrate_chain_rows.sql:
  133. [code]create table t05318_chain(a varchar2(2000), b varchar2(2000), c varchar2(2000), d varchar2(2000));

  134. insert into t05318_chain(a) values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';

  139. select  * from t05318_chain;

  140. select  * from CHAINED_ROWS;

  141. analyze table t05318_chain  list chained rows;

  142. select  * from CHAINED_ROWS;

  143. update t05318_chain set d='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';

  144. analyze table t05318_chain  list chained rows;

  145. select  * from CHAINED_ROWS;

  146. select  * from dba_tablespaces;

  147. select  * from dba_Tables t where t.owner='HR' and t.table_name='T05318_CHAIN';

  148. create tablespace tbs16k  datafile size 5M blocksize  16384;

  149. alter system set db_16k_cache_size=1M;

  150. create tablespace tbs16k  datafile size 5M blocksize  16384;

  151. alter table hr.T05318_CHAIN move tablespace tbs16k;

  152. select  * from CHAINED_ROWS;

  153. analyze table t05318_chain  list chained rows;


  154. select  * from CHAINED_ROWS;

  155. -----

  156. create table t05318_migrate( a varchar2(2000))  pctfree 0;

  157. truncate  table t05318_migrate;

  158. begin
  159.    for i in 1..733
  160.    loop
  161.       insert into  t05318_migrate values('A');
  162.     end loop;
  163.     commit;
  164. end;


  165. analyze table t05318_migrate  list chained rows;

  166. select  * from CHAINED_ROWS;

  167. select     distinct dbms_rowid.rowid_block_number(rowid)
  168.    from t05318_migrate;


  169. select      dbms_rowid.rowid_block_number(rowid)  myrow ,count( dbms_rowid.rowid_block_number(rowid)  )
  170.    from t05318_migrate  group by    dbms_rowid.rowid_block_number(rowid)     ;
  171.    
  172.    insert into    t05318_migrate values('A');
  173.    
  174.    
  175.    update  t05318_migrate set a='AAAAAA';
  176.    
  177.    analyze table t05318_migrate  list chained rows;

  178. select  * from CHAINED_ROWS;

  179. select     distinct dbms_rowid.rowid_block_number(rowid)
  180.    from t05318_migrate;


  181. select      dbms_rowid.rowid_block_number(rowid)  myrow ,count( dbms_rowid.rowid_block_number(rowid)  )
  182.    from t05318_migrate  group by    dbms_rowid.rowid_block_number(rowid)     ;
  183.    
  184.    select * from user_Tables t where t.TABLE_NAME='T05318_MIGRATE';
  185.    
  186.    
  187.    alter table T05318_MIGRATE  move tablespace users;
  188.    
  189.    truncate table CHAINED_ROWS;
  190.    
  191.    analyze table t05318_migrate  list chained rows;

  192. select  * from CHAINED_ROWS;

  193. select     distinct dbms_rowid.rowid_block_number(rowid)
  194.    from t05318_migrate;


  195. select      dbms_rowid.rowid_block_number(rowid)  myrow ,count( dbms_rowid.rowid_block_number(rowid)  )
  196.    from t05318_migrate  group by    dbms_rowid.rowid_block_number(rowid)     ;
  197.    
  198.    
复制代码

compress.sql:

  1. --sys--
  2. create tablespace tbs_nocompression datafile size 10M autoextend on;
  3. create tablespace tbs_basic datafile size 10M autoextend on default compress basic;
  4. create tablespace tbs_oltp datafile size 10M autoextend on default compress for oltp;
  5. create tablespace tbs_query datafile size 10M autoextend on default compress for query;
  6. create tablespace tbs_archive datafile size 10M autoextend on default compress for archive;
  7. select  t.tablespace_name, t.def_tab_compression, t.compress_for  from dba_tablespaces t
  8. where t.tablespace_name in ('TBS_NOCOMPRESSION',
  9.                                                   'TBS_BASIC', 'TBS_OLTP',
  10.                                                    'TBS_QUERY',
  11.                                                    'TBS_ARCHIVE');
  12. --hr--                                                   
  13. create table t_nocompression (a varchar2(200)) tablespace tbs_nocompression;
  14. create table t_basic (a varchar2(200)) tablespace tbs_basic;
  15. create table t_oltp (a varchar2(200)) tablespace tbs_oltp;
  16. --hr-error--
  17. create table t_query (a varchar2(200)) tablespace tbs_query;
  18. create table t_archive (a varchar2(200)) tablespace tbs_archive;  
  19. --hr--
  20. begin
  21.    for i in 1..400
  22.    loop
  23.       insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
  24.    end loop;
  25.    commit;
  26. end;
  27. --hr--
  28. begin
  29.    for i in 1..400
  30.    loop
  31.       insert into t_basic values('AAAAAAAAAAAAAAAAAAAA');
  32.    end loop;
  33.    commit;
  34. end;
  35. --hr--
  36. begin
  37.    for i in 1..400
  38.    loop
  39.       insert into t_oltp values('AAAAAAAAAAAAAAAAAAAA');
  40.    end loop;
  41.    commit;
  42. end;  
  43. --hr--
  44. select  t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
  45. from user_tables t where t.TABLE_NAME   in ('T_NOCOMPRESSION','T_BASIC','T_OLTP');
  46. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );
  47. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );      
  48. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_oltp  group by  substr(rowid, 10, 6 );  
  49. --sys--
  50. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  51.       from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
  52. --sys--
  53. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
  54.       from hr.T_BASIC group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
  55. --sys--      
  56. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP',row_id => rowid)
  57.       from hr.T_OLTP group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP',row_id => rowid);
  58. --hr--      
  59. create table t_basic2 (a varchar2(200)) tablespace tbs_nocompression compress;
  60. create table t_oltp2 (a varchar2(200)) tablespace tbs_nocompression compress for oltp;
  61. --hr-error--
  62. create table t_query2 (a varchar2(200)) tablespace tbs_nocompression compress for query;
  63. create table t_archive2 (a varchar2(200)) tablespace tbs_nocompression compress for archive;     
  64. --hr--
  65. select  t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
  66. from user_tables t where t.TABLE_NAME   in ('T_NOCOMPRESSION','T_BASIC','T_OLTP',  'T_BASIC2','T_OLTP2' );
  67. --hr--
  68. begin
  69.    for i in 1..400
  70.    loop
  71.       insert into t_basic2 values('AAAAAAAAAAAAAAAAAAAA');
  72.    end loop;
  73.    commit;
  74. end;
  75. --hr--
  76. begin
  77.    for i in 1..400
  78.    loop
  79.       insert into t_oltp2 values('AAAAAAAAAAAAAAAAAAAA');
  80.    end loop;
  81.    commit;
  82. end;
  83. --hr--
  84. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic2  group by  substr(rowid, 10, 6 );
  85. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_oltp2  group by  substr(rowid, 10, 6 );
  86. --sys--
  87. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC2',row_id => rowid)
  88.       from hr.T_BASIC2 group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC2',row_id => rowid);
  89. --sys--      
  90. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP2',row_id => rowid)
  91.       from hr.T_OLTP2 group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP2',row_id => rowid);
  92. --hr--
  93. alter table t_nocompression compress for oltp;
  94. select  t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
  95. from user_tables t where t.TABLE_NAME   in ('T_NOCOMPRESSION','T_BASIC','T_OLTP',  'T_BASIC2','T_OLTP2' );
  96. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );     
  97. --sys--
  98. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  99.    from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);   
  100. --hr--
  101. begin
  102.    for i in 1..400
  103.    loop
  104.       insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
  105.    end loop;
  106.    commit;
  107. end;
  108. --hr--
  109. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );
  110. --sys--
  111. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  112.       from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
  113. --hr--
  114. alter table t_nocompression move tablespace tbs_nocompression;
  115. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );   
  116. --sys--
  117. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  118.       from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
  119. --hr--
  120. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );  
  121. insert /*+ append */ into t_basic select  * from  t_basic;
  122. commit;
  123. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );
  124. --sys--
  125. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
  126.       from hr.T_BASIC group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
  127. --hr--
  128. alter table t_basic move tablespace  TBS_NOCOMPRESSION;
  129. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );      
  130. --sys--
  131. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
  132.       from hr.T_BASIC group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
  133. --sys-evolution--
  134. drop table hr.t_basic_big;
  135. create table hr.t_basic_big compress as select  * from dba_source;
  136. --sys-advisor--
  137. declare
  138.   v_blkcnt_cmp number;
  139.   v_blkcnt_uncmp  number;
  140.   v_row_cmp number;
  141.   v_row_uncmp number;
  142.   v_cmp_ratio number;
  143.   v_comptype_str  varchar2(200);
  144. BEGIN
  145. DBMS_COMPRESSION.GET_COMPRESSION_RATIO(scratchtbsname => 'USERS',
  146.                                                                                              ownname =>'HR',
  147.                                                                                              tabname =>'T_BASIC_BIG',
  148.                                                                                              partname =>null,
  149.                                                                                              comptype => 2,
  150.                                                                                              blkcnt_cmp => v_blkcnt_cmp,
  151.                                                                                              blkcnt_uncmp =>  v_blkcnt_uncmp,
  152.                                                                                              row_cmp =>v_row_cmp,
  153.                                                                                              row_uncmp => v_row_uncmp,
  154.                                                                                              cmp_ratio =>  v_cmp_ratio,
  155.                                                                                              comptype_str =>v_comptype_str);                                                  
  156. DBMS_OUTPUT.PUT_LINE('Blk count compressed = ' || v_blkcnt_cmp);
  157. DBMS_OUTPUT.PUT_LINE('Blk count uncompressed = ' || v_blkcnt_uncmp);
  158. DBMS_OUTPUT.PUT_LINE('Row count per block compressed = ' || v_row_cmp);
  159. DBMS_OUTPUT.PUT_LINE('Row count per block uncompressed = ' || v_row_uncmp);
  160. DBMS_OUTPUT.PUT_LINE('ratio: '||v_cmp_ratio);
  161. DBMS_OUTPUT.PUT_LINE('Compression type = ' || v_comptype_str);
  162. end;
  163. --sys--
  164. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC_BIG',row_id => rowid)
  165.       from hr.T_BASIC_BIG group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC_BIG',row_id => rowid);  
  166. --hr--
  167. create table t_basic_col( a  number , b varchar2(20))  compress ;
  168. insert into t_basic_col values ( 1,'A') ;
  169. commit;
  170. create table t_oltp_col( a  number , b varchar2(20))  compress  for oltp;
  171. insert into t_oltp_col values ( 1,'A') ;
  172. commit;
  173. select  * from  t_basic_col;
  174. select  * from t_oltp_col;
  175. alter table  t_basic_col drop column b;
  176. alter table  t_basic_col drop ( b);
  177. alter table t_oltp_col drop column b;
  178. select  * from t_oltp_col;

复制代码



);
                                            
                                            end;
                                            
   select dbms_hm.get_run_report('mycheck') from dual;


select  * from dba_segments s where s.owner='HR' and s.segment_name='I05318_PART';

select  * from dba_ind_partitions ip where ip.index_owner='HR' and ip.index_name='I05318_PART';

select   s.segment_name ,s.bytes/1024/1024  from dba_segments s where s.owner='HR' and s.segment_name='I05318_A';

select  i.index_name,i.compression
  from dba_indexes i where i.owner='HR' and i.index_name='I05318_A'  ;



                                         
                                            [/code]





migrate_chain_rows.sql:
  1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aaaaaaaaaaaaaaaaaaaaaa';

  12. analyze table t05318_chain  list chained rows;

  13. select  * from CHAINED_ROWS;

  14. select  * from dba_tablespaces;

  15. select  * from dba_Tables t where t.owner='HR' and t.table_name='T05318_CHAIN';

  16. create tablespace tbs16k  datafile size 5M blocksize  16384;

  17. alter system set db_16k_cache_size=1M;

  18. create tablespace tbs16k  datafile size 5M blocksize  16384;

  19. alter table hr.T05318_CHAIN move tablespace tbs16k;

  20. select  * from CHAINED_ROWS;

  21. analyze table t05318_chain  list chained rows;


  22. select  * from CHAINED_ROWS;

  23. -----

  24. create table t05318_migrate( a varchar2(2000))  pctfree 0;

  25. truncate  table t05318_migrate;

  26. begin
  27.    for i in 1..733
  28.    loop
  29.       insert into  t05318_migrate values('A');
  30.     end loop;
  31.     commit;
  32. end;


  33. analyze table t05318_migrate  list chained rows;

  34. select  * from CHAINED_ROWS;

  35. select     distinct dbms_rowid.rowid_block_number(rowid)
  36.    from t05318_migrate;


  37. select      dbms_rowid.rowid_block_number(rowid)  myrow ,count( dbms_rowid.rowid_block_number(rowid)  )
  38.    from t05318_migrate  group by    dbms_rowid.rowid_block_number(rowid)     ;
  39.    
  40.    insert into    t05318_migrate values('A');
  41.    
  42.    
  43.    update  t05318_migrate set a='AAAAAA';
  44.    
  45.    analyze table t05318_migrate  list chained rows;

  46. select  * from CHAINED_ROWS;

  47. select     distinct dbms_rowid.rowid_block_number(rowid)
  48.    from t05318_migrate;


  49. select      dbms_rowid.rowid_block_number(rowid)  myrow ,count( dbms_rowid.rowid_block_number(rowid)  )
  50.    from t05318_migrate  group by    dbms_rowid.rowid_block_number(rowid)     ;
  51.    
  52.    select * from user_Tables t where t.TABLE_NAME='T05318_MIGRATE';
  53.    
  54.    
  55.    alter table T05318_MIGRATE  move tablespace users;
  56.    
  57.    truncate table CHAINED_ROWS;
  58.    
  59.    analyze table t05318_migrate  list chained rows;

  60. select  * from CHAINED_ROWS;

  61. select     distinct dbms_rowid.rowid_block_number(rowid)
  62.    from t05318_migrate;


  63. select      dbms_rowid.rowid_block_number(rowid)  myrow ,count( dbms_rowid.rowid_block_number(rowid)  )
  64.    from t05318_migrate  group by    dbms_rowid.rowid_block_number(rowid)     ;
  65.    
  66.    
复制代码

compress.sql:

  1. --sys--
  2. create tablespace tbs_nocompression datafile size 10M autoextend on;
  3. create tablespace tbs_basic datafile size 10M autoextend on default compress basic;
  4. create tablespace tbs_oltp datafile size 10M autoextend on default compress for oltp;
  5. create tablespace tbs_query datafile size 10M autoextend on default compress for query;
  6. create tablespace tbs_archive datafile size 10M autoextend on default compress for archive;
  7. select  t.tablespace_name, t.def_tab_compression, t.compress_for  from dba_tablespaces t
  8. where t.tablespace_name in ('TBS_NOCOMPRESSION',
  9.                                                   'TBS_BASIC', 'TBS_OLTP',
  10.                                                    'TBS_QUERY',
  11.                                                    'TBS_ARCHIVE');
  12. --hr--                                                   
  13. create table t_nocompression (a varchar2(200)) tablespace tbs_nocompression;
  14. create table t_basic (a varchar2(200)) tablespace tbs_basic;
  15. create table t_oltp (a varchar2(200)) tablespace tbs_oltp;
  16. --hr-error--
  17. create table t_query (a varchar2(200)) tablespace tbs_query;
  18. create table t_archive (a varchar2(200)) tablespace tbs_archive;  
  19. --hr--
  20. begin
  21.    for i in 1..400
  22.    loop
  23.       insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
  24.    end loop;
  25.    commit;
  26. end;
  27. --hr--
  28. begin
  29.    for i in 1..400
  30.    loop
  31.       insert into t_basic values('AAAAAAAAAAAAAAAAAAAA');
  32.    end loop;
  33.    commit;
  34. end;
  35. --hr--
  36. begin
  37.    for i in 1..400
  38.    loop
  39.       insert into t_oltp values('AAAAAAAAAAAAAAAAAAAA');
  40.    end loop;
  41.    commit;
  42. end;  
  43. --hr--
  44. select  t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
  45. from user_tables t where t.TABLE_NAME   in ('T_NOCOMPRESSION','T_BASIC','T_OLTP');
  46. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );
  47. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );      
  48. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_oltp  group by  substr(rowid, 10, 6 );  
  49. --sys--
  50. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  51.       from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
  52. --sys--
  53. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
  54.       from hr.T_BASIC group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
  55. --sys--      
  56. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP',row_id => rowid)
  57.       from hr.T_OLTP group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP',row_id => rowid);
  58. --hr--      
  59. create table t_basic2 (a varchar2(200)) tablespace tbs_nocompression compress;
  60. create table t_oltp2 (a varchar2(200)) tablespace tbs_nocompression compress for oltp;
  61. --hr-error--
  62. create table t_query2 (a varchar2(200)) tablespace tbs_nocompression compress for query;
  63. create table t_archive2 (a varchar2(200)) tablespace tbs_nocompression compress for archive;     
  64. --hr--
  65. select  t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
  66. from user_tables t where t.TABLE_NAME   in ('T_NOCOMPRESSION','T_BASIC','T_OLTP',  'T_BASIC2','T_OLTP2' );
  67. --hr--
  68. begin
  69.    for i in 1..400
  70.    loop
  71.       insert into t_basic2 values('AAAAAAAAAAAAAAAAAAAA');
  72.    end loop;
  73.    commit;
  74. end;
  75. --hr--
  76. begin
  77.    for i in 1..400
  78.    loop
  79.       insert into t_oltp2 values('AAAAAAAAAAAAAAAAAAAA');
  80.    end loop;
  81.    commit;
  82. end;
  83. --hr--
  84. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic2  group by  substr(rowid, 10, 6 );
  85. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_oltp2  group by  substr(rowid, 10, 6 );
  86. --sys--
  87. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC2',row_id => rowid)
  88.       from hr.T_BASIC2 group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC2',row_id => rowid);
  89. --sys--      
  90. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP2',row_id => rowid)
  91.       from hr.T_OLTP2 group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP2',row_id => rowid);
  92. --hr--
  93. alter table t_nocompression compress for oltp;
  94. select  t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
  95. from user_tables t where t.TABLE_NAME   in ('T_NOCOMPRESSION','T_BASIC','T_OLTP',  'T_BASIC2','T_OLTP2' );
  96. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );     
  97. --sys--
  98. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  99.    from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);   
  100. --hr--
  101. begin
  102.    for i in 1..400
  103.    loop
  104.       insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
  105.    end loop;
  106.    commit;
  107. end;
  108. --hr--
  109. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );
  110. --sys--
  111. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  112.       from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
  113. --hr--
  114. alter table t_nocompression move tablespace tbs_nocompression;
  115. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_nocompression  group by  substr(rowid, 10, 6 );   
  116. --sys--
  117. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
  118.       from hr.T_NOCOMPRESSION  group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
  119. --hr--
  120. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );  
  121. insert /*+ append */ into t_basic select  * from  t_basic;
  122. commit;
  123. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );
  124. --sys--
  125. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
  126.       from hr.T_BASIC group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
  127. --hr--
  128. alter table t_basic move tablespace  TBS_NOCOMPRESSION;
  129. select  count(*)  , substr(rowid, 10, 6 ) from hr.t_basic  group by  substr(rowid, 10, 6 );      
  130. --sys--
  131. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
  132.       from hr.T_BASIC group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
  133. --sys-evolution--
  134. drop table hr.t_basic_big;
  135. create table hr.t_basic_big compress as select  * from dba_source;
  136. --sys-advisor--
  137. declare
  138.   v_blkcnt_cmp number;
  139.   v_blkcnt_uncmp  number;
  140.   v_row_cmp number;
  141.   v_row_uncmp number;
  142.   v_cmp_ratio number;
  143.   v_comptype_str  varchar2(200);
  144. BEGIN
  145. DBMS_COMPRESSION.GET_COMPRESSION_RATIO(scratchtbsname => 'USERS',
  146.                                                                                              ownname =>'HR',
  147.                                                                                              tabname =>'T_BASIC_BIG',
  148.                                                                                              partname =>null,
  149.                                                                                              comptype => 2,
  150.                                                                                              blkcnt_cmp => v_blkcnt_cmp,
  151.                                                                                              blkcnt_uncmp =>  v_blkcnt_uncmp,
  152.                                                                                              row_cmp =>v_row_cmp,
  153.                                                                                              row_uncmp => v_row_uncmp,
  154.                                                                                              cmp_ratio =>  v_cmp_ratio,
  155.                                                                                              comptype_str =>v_comptype_str);                                                  
  156. DBMS_OUTPUT.PUT_LINE('Blk count compressed = ' || v_blkcnt_cmp);
  157. DBMS_OUTPUT.PUT_LINE('Blk count uncompressed = ' || v_blkcnt_uncmp);
  158. DBMS_OUTPUT.PUT_LINE('Row count per block compressed = ' || v_row_cmp);
  159. DBMS_OUTPUT.PUT_LINE('Row count per block uncompressed = ' || v_row_uncmp);
  160. DBMS_OUTPUT.PUT_LINE('ratio: '||v_cmp_ratio);
  161. DBMS_OUTPUT.PUT_LINE('Compression type = ' || v_comptype_str);
  162. end;
  163. --sys--
  164. select   count(*)  ,    dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC_BIG',row_id => rowid)
  165.       from hr.T_BASIC_BIG group by     dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC_BIG',row_id => rowid);  
  166. --hr--
  167. create table t_basic_col( a  number , b varchar2(20))  compress ;
  168. insert into t_basic_col values ( 1,'A') ;
  169. commit;
  170. create table t_oltp_col( a  number , b varchar2(20))  compress  for oltp;
  171. insert into t_oltp_col values ( 1,'A') ;
  172. commit;
  173. select  * from  t_basic_col;
  174. select  * from t_oltp_col;
  175. alter table  t_basic_col drop column b;
  176. alter table  t_basic_col drop ( b);
  177. alter table t_oltp_col drop column b;
  178. select  * from t_oltp_col;

复制代码

  1. create table hr.tbig as select  * from dba_source;

  2. select  segment_name , bytes from dba_segments where segment_name='T_BASIC_BIG';

  3. grant resumable to hr;


  4. select    file_name,  bytes/1024/1024  from dba_data_files where tablespace_name='TBSSUS';

  5. select  bytes/1024/1024 from dba_segments where segment_name='T05318_B';

  6. alter database datafile '+DATA/orcl/datafile/tbs05318_small.279.881085711' resize 70M;


  7. CREATE OR REPLACE TRIGGER SYS.TRG_SUSPEND
  8. AFTER SUSPEND
  9. ON DATABASE
  10. declare
  11. v_size number;
  12.   pragma AUTONOMOUS_TRANSACTION;
  13. begin
  14.   select  bytes into v_size from dba_data_files where  file_name='+DATA/orcl/datafile/tbssus.280.881086139';
  15.   v_size := v_size +5242880 ;
  16.   execute immediate 'alter database datafile  ''+DATA/orcl/datafile/tbssus.280.881086139''  resize '||v_size;
  17. commit;
  18. end;
复制代码
  1. SQL> create table t05318_part (  a  number )
  2.   2  partition by range (a)
  3.   3  (partition p1 values less than (10),
  4.   4   partition p2 values less than (maxvalue)) ;

  5. Table created.

  6. SQL> insert into t05318_part  values (9) ;

  7. 1 row created.

  8. SQL> insert into t05318_part  values (10) ;

  9. 1 row created.

  10. SQL> commit;

  11. Commit complete.

  12. SQL> select * from t05318_part ;

  13.          A
  14. ----------
  15.          9
  16.         10

  17. SQL> select * from t05318_part  partition(p1) ;

  18.          A
  19. ----------
  20.          9

  21. SQL> select * from t05318_part  partition(p2) ;

  22.          A
  23. ----------
  24.         10

  25. SQL> create index i05318_part on t05318_part(a)  local ;

  26. Index created.

  27. SQL> alter table t05318_part move partition p1 tablespace example ;

  28. Table altered.

  29. SQL>  alter  index  i05318_part  partition p1 rebuild;
  30. alter        index  i05318_part  partition p1 rebuild
  31.                                          *
  32. ERROR at line 1:
  33. ORA-02243: invalid ALTER INDEX or ALTER MATERIALIZED VIEW option


  34. SQL>  alter  index  i05318_part  rebuild   partition p1 ;

  35. Index altered.

  36. SQL>
复制代码


oracle-internal1.pdf

9.45 KB, 下载次数: 51

oracle-internal1.pdf

9.45 KB, 下载次数: 49

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-22 00:50 , Processed in 0.052024 second(s), 27 queries .

快速回复 返回顶部 返回列表