本帖最后由 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 - #!/bin/sh
- v_dbname=orcl
- su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/srvctl stop database -d $v_dbname"
- su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus /nolog" <<EOF
- conn / as sysdba
- startup mount exclusive
- EOF
- rm -f /home/oracle/example01.dbf 2>/dev/null
- su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target /" <<EOF
- backup as copy datafile 5 format '/home/oracle/example01.dbf';
- EOF
- dd if=/dev/zero of=/home/oracle/example01.dbf bs=8192 count=1 seek=175 conv=notrunc
- 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
- rm -f +data/$v_dbname/DATAFILE/example*
- EOF
- su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target /" <<EOF
- run {
- set maxcorrupt for datafile 5 to 1;
- backup as copy datafilecopy '/home/oracle/example01.dbf' format '+data';
- }
- EOF
- sleep 3
- su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target /" <<EOF
- delete noprompt datafilecopy '/home/oracle/example01.dbf';
- switch datafile 5 to copy;
- EOF
- su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus /nolog" <<EOF
- conn / as sysdba
- alter database open;
- EOF
复制代码
2014-11-06-dbms_repair.sql: - select * from dba_indexes i where i.owner='HR' and i.table_name='T05309';
- select * from REPAIR_TABLE;
- BEGIN
- DBMS_REPAIR.ADMIN_TABLES (
- table_name => 'REPAIR_TABLE',
- table_type => DBMS_REPAIR.REPAIR_TABLE,
- action => DBMS_REPAIR.CREATE_ACTION,
- tablespace => 'USERS');
- END;
- select * from REPAIR_TABLE;
- select * from ORPHAN_KEY_TABLE;
- BEGIN
- DBMS_REPAIR.ADMIN_TABLES (
- table_name => 'ORPHAN_KEY_TABLE',
- table_type => DBMS_REPAIR.ORPHAN_TABLE,
- action => DBMS_REPAIR.CREATE_ACTION,
- tablespace => 'USERS');
- END;
- select * from ORPHAN_KEY_TABLE;
- DECLARE num_corrupt INT;
- BEGIN
- num_corrupt := 0;
- DBMS_REPAIR.CHECK_OBJECT (
- schema_name => 'HR',
- object_name => 'T05309',
- repair_table_name => 'REPAIR_TABLE',
- corrupt_count => num_corrupt);
- dbms_output.put_line( 'Find '|| num_corrupt||' Bolcks.' );
- END;
- select * from REPAIR_TABLE;
- DECLARE num_fix INT;
- BEGIN
- num_fix := 0;
- DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
- schema_name => 'HR',
- object_name => 'T05309',
- object_type => DBMS_REPAIR.TABLE_OBJECT,
- repair_table_name => 'REPAIR_TABLE',
- fix_count => num_fix);
- END;
- select * from REPAIR_TABLE;
- DECLARE num_orphans INT;
- BEGIN
- num_orphans := 0;
- DBMS_REPAIR.DUMP_ORPHAN_KEYS (
- schema_name => 'HR',
- object_name => 'I1_05309',
- object_type => DBMS_REPAIR.INDEX_OBJECT,
- repair_table_name => 'REPAIR_TABLE',
- orphan_table_name => 'ORPHAN_KEY_TABLE',
- key_count => num_orphans);
- DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
- END;
- select * from ORPHAN_KEY_TABLE;
- DECLARE num_orphans INT;
- BEGIN
- num_orphans := 0;
- DBMS_REPAIR.DUMP_ORPHAN_KEYS (
- schema_name => 'HR',
- object_name => 'I2_05309',
- object_type => DBMS_REPAIR.INDEX_OBJECT,
- repair_table_name => 'REPAIR_TABLE',
- orphan_table_name => 'ORPHAN_KEY_TABLE',
- key_count => num_orphans);
- DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
- END;
- select * from ORPHAN_KEY_TABLE;
- select * from ORPHAN_KEY_TABLE where keyrowid||' '='AAASNiAIgAAAIABAAA'||' ';
- select dump(o.key)
- from ORPHAN_KEY_TABLE o;
- begin
- dbms_repair.skip_corrupt_blocks(schema_name => 'HR',object_name => 'T05309');
- end;
复制代码
|