[20210318]bbed讀取資料塊2.txt

lfree發表於2021-03-19

[20210318]bbed讀取資料塊2.txt

1.環境:
SCOTT@book> @ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> create table t as select * from all_objects where rownum<=1000;
Table created.

SCOTT@book> select object_id,data_object_id from dba_objects where owner=user and object_name='T';
 OBJECT_ID DATA_OBJECT_ID
---------- --------------
     90967          90967

2.建立指令碼,測試讀取看看。

$ cat fff.sh
#! /bin/bash -x
# argv1=file_number argv2=begin_block argvs3=end_block argv4=data_object_id
file_number=$1
begin_block=$2
end_block=$3
data_object_id=$4

# scan1 begin_block to end_block,define Scope.
/bin/rm scan1.txt
while [ $begin_block -le $end_block ]
do
    v_object_id=$(echo "p /d dba $file_number,$begin_block  ktbbh.ktbbhsid.ktbbhod1" | rlbbed | grep ktbbhod1 |awk '{print $NF}')
    if [ -z "$v_object_id" ]
    then
            v_object_id=0
    fi

    if (( $v_object_id == $data_object_id ))
    then
            echo $file_number,$begin_block >> scan1.txt
    fi
    begin_block=$[ begin_block + 1 ]
done

# scan2 kdbr and display record.

cat scan1.txt |while read dba
do
    #echo set dba $dba
    kdbr_size=$(echo map dba $dba | rlbbed | grep "sb2 kdbr" | sed -e "s/^.*\[//;s/].*$//")
    #echo $kdbr_size

    begin=0
    end=$[ kdbr_size -1 ]
    #echo $begin $end

    while [ $begin -le $end ]
    do
        kdbr_off=$(echo p dba $dba offset 0 kdbr | rlbbed | grep "sb2 kdbr\[$begin\]" | awk '{print $NF'})
        #echo $kdbr_off
        #if [ $kdbr_off -gt $kdbr_size ]
        #if [[ $kdbr_off > $kdbr_size ]]
        if (( $kdbr_off > $kdbr_size ))
        then
            echo -n "x /rcccnncttcccccnc dba $dba *kdbr[$begin]" | rlbbed  | grep "^col " | cut -c20- |  paste -sd'|'
        fi
        begin=$[ begin + 1 ]
    done
done

3.恢復看看:
$ . fff.sh 4 731 800 90967 >|laji.txt

--//使用toad匯入
--//整理本文如下,使用vim的替換功能:
--//:%s+ |+|+g
--//:%s+ $++g
--//:%s+|\*NULL\*|++g

4.測試恢復情況:
--//匯入細節略,我是使用toad自帶的import功能實現的,步驟有點煩鎖。
SCOTT@book> create table ty as select * from all_objects where 1=2;
Table created.

SCOTT@book> select * from t minus select * from ty;
no rows selected

SCOTT@book> select * from ty minus select * from t;
no rows selected

5.總結:
--//不是很實用,如果delete記錄,輸出會出現空行。而且記錄多,處理起來很慢。
--//無法解決行連結和行遷移問題。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2763810/,如需轉載,請註明出處,否則將追究法律責任。

相關文章