Bo's Oracle Station

查看: 2052|回复: 0

第60次:2014-11-06, 053第 9章

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2014-11-10 11:25:10 | 显示全部楼层 |阅读模式
本帖最后由 botang 于 2014-11-27 10:27 编辑

100^(193-193-0)(2-1)=1
100^(193-193-0)(11-1)=10
100^(194-193-0)(2-1)=100
100^(194-193-0)(11-1)=1000
100^(194-193-0)(2-1)+
   100^(194-193-1)(11-1)=110
100^(194-193-0)(12-1)=1100
100^(62-62-0)(101-100)=1
100^(62-62-0)(101-91)=10
100^(62-61-0)(101-100)=100
123456.789
100^(195-193-0)(13-1)+
100^(195-193-1)(35-1)+
100^(195-193-2)(57-1)+
100^(195-193-3)(79-1)+
100^(195-193-4)(91-1)=120000+3400+56+0.78+0.009=
123456.789
-123456.789
100^(62-60-0)(101-89)+
100^(62-60-1)(101-67)+
100^(62-60-2)(101-45)+
100^(62-60-3)(101-23)+
100^(62-60-4)(101-11)=120000+3400+56+0.78+0.009=
-123456.789
-123456.78901
100^(62-60-0)(101-89)+
100^(62-60-1)(101-67)+
100^(62-60-2)(101-45)+
100^(62-60-3)(101-23)+
100^(62-60-4)(101-11)+
100^(62-60-5)(101-91)
=120000+3400+56+0.78+0.009+ 0.00001=
-123456.78901
physical-block.sh
  1. #!/bin/sh
  2. v_dbname=orcl
  3. su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/srvctl stop database -d $v_dbname"
  4. su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus /nolog" <<EOF
  5. conn / as sysdba
  6. startup mount exclusive
  7. EOF

  8. rm -f /home/oracle/example01.dbf 2>/dev/null

  9. su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target /" <<EOF
  10. backup as copy datafile 5 format '/home/oracle/example01.dbf';
  11. EOF

  12. dd if=/dev/zero of=/home/oracle/example01.dbf bs=8192 count=1 seek=175 conv=notrunc

  13. su - oracle -c "export ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid ; export ORACLE_SID=+ASM ; /u01/app/oracle/product/11.2.0/grid/bin/asmcmd" <<EOF
  14. rm -f +data/$v_dbname/DATAFILE/example*
  15. EOF

  16. su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target /" <<EOF
  17. run {
  18. set maxcorrupt for datafile 5 to 1;
  19. backup as copy  datafilecopy '/home/oracle/example01.dbf' format '+data';
  20. }
  21. EOF

  22. sleep 3

  23. su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target /" <<EOF
  24. delete noprompt datafilecopy '/home/oracle/example01.dbf';
  25. switch datafile 5 to copy;
  26. EOF


  27. su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus /nolog" <<EOF
  28. conn / as sysdba
  29. alter database open;
  30. EOF
复制代码

2014-11-06-dbms_repair.sql:
  1. select  * from dba_indexes i where i.owner='HR' and i.table_name='T05309';

  2. select  * from  REPAIR_TABLE;


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


  10. select  * from  REPAIR_TABLE;

  11. select  * from ORPHAN_KEY_TABLE;

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

  19. select  * from ORPHAN_KEY_TABLE;

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

  30. select  * from  REPAIR_TABLE;

  31. DECLARE num_fix INT;
  32. BEGIN
  33. num_fix := 0;
  34. DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
  35.            schema_name => 'HR',
  36.            object_name => 'T05309',
  37.            object_type => DBMS_REPAIR.TABLE_OBJECT,
  38.            repair_table_name => 'REPAIR_TABLE',
  39.    fix_count => num_fix);
  40. END;

  41. select  * from  REPAIR_TABLE;


  42. DECLARE num_orphans INT;
  43. BEGIN
  44. num_orphans := 0;
  45. DBMS_REPAIR.DUMP_ORPHAN_KEYS (
  46.   schema_name => 'HR',
  47.   object_name => 'I1_05309',
  48.   object_type => DBMS_REPAIR.INDEX_OBJECT,
  49.   repair_table_name => 'REPAIR_TABLE',
  50.   orphan_table_name => 'ORPHAN_KEY_TABLE',
  51.   key_count => num_orphans);
  52. DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
  53. END;

  54. select  * from ORPHAN_KEY_TABLE;

  55. DECLARE num_orphans INT;
  56. BEGIN
  57. num_orphans := 0;
  58. DBMS_REPAIR.DUMP_ORPHAN_KEYS (
  59.   schema_name => 'HR',
  60.   object_name => 'I2_05309',
  61.   object_type => DBMS_REPAIR.INDEX_OBJECT,
  62.   repair_table_name => 'REPAIR_TABLE',
  63.   orphan_table_name => 'ORPHAN_KEY_TABLE',
  64.   key_count => num_orphans);
  65. DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
  66. END;


  67. select  * from ORPHAN_KEY_TABLE;

  68. select  * from ORPHAN_KEY_TABLE where keyrowid||' '='AAASNiAIgAAAIABAAA'||' ';

  69. select dump(o.key)
  70. from ORPHAN_KEY_TABLE  o;

  71. begin
  72.    dbms_repair.skip_corrupt_blocks(schema_name => 'HR',object_name => 'T05309');
  73.   end;
复制代码





回复

使用道具 举报

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

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-12-4 16:33 , Processed in 0.033297 second(s), 24 queries .

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