ORACLE故障排除 注意事項

2021-04-12 23:01:26 字數 2335 閱讀 4695

1.在系統良好運作時, 進行一次statspack! 並將結果檔案儲存作為以後的判斷標準.

2.oracle中建立一張存放有執行計畫的表

指令碼如下:

--建立一張計畫表

create table plan_hashes

( sql_text

varchar2(1000),

hash_value

number,

plan_hash_value

number,

constraint plan_hashes_pk

primary key(hash_value,sql_text,plan_hash_value)

)organization index;

--將shared_pool中的語句插入計畫表

insert into plan_hashes( sql_text, hash_value, plan_hash_value )

select distinct sql_text,

hash_value,

plan_hash_value

from v$sql

where command_type in (

/* delete */ 7,

/* insert */ 2,

/* merge */ 189, /* select */ 3,

/* update */ 6 )

and parsing_user_id <> 0

and parsing_schema_id <> 0;

--檢視當前shared pool中的執行計畫與計畫表的差異

select distinct sql_text,

hash_value,

plan_hash_value,

decode( (select 1

from plan_hashes

where plan_hashes.hash_value = v$sql.hash_value

and plan_hashes.sql_text = v$sql.sql_text

and rownum = 1), 1, 'changed', 'new' ) status

from v$sql

where (sql_text, hash_value, plan_hash_value)

not in (select sql_text, hash_value, plan_hash_value

from plan_hashes)

and command_type in (

/* delete */ 7,

/* insert */ 2,

/* merge */ 189, /* select */ 3,

/* update */ 6 )

and parsing_user_id <> 0

and parsing_schema_id <> 0

/--shared_pool中新的執行計畫存入計畫表

insert into plan_hashes( sql_text, hash_value, plan_hash_value )

select distinct sql_text,

hash_value,

plan_hash_value

from v$sql

where (sql_text, hash_value, plan_hash_value)

not in (select sql_text, hash_value, plan_hash_value

from plan_hashes)

and command_type in (

/* delete */ 7,

/* insert */ 2,

/* merge */ 189, /* select */ 3,

/* update */ 6 )

and parsing_user_id <> 0

and parsing_schema_id <> 0

/3.找出差異

收集了之前的歷史資料,我們就能通過比對找出兩者之間的差別

4.每次只更改乙個問題

不要多個人同時更改多個問題,也不要乙個人更改多個問題,這樣就無法確定到底是哪個變動解決了問題所在

5.確認是否需要修改這個問題

改動乙個問題之前要先確定目標,並且經過驗證(小規模的基準測試是必要的)之後才能動手

6.做好備份

任何改動之前都需要進行備份,使系統能夠回退到改動前的狀態時必須的

7.建立小型的測試用例

由於系統可能會很龐大,執行起來相當複雜耗時,所以需要盡可能多的剝離不需要的**,使用簡單,明了的測試用例重現錯誤!

oracle注意事項

建立序列 create sequence role seq1 start with 1 increment by 1 minvalue 1 maxvalue 1000 nocycle nocache drop刪除序列 drop sequence role seq1 primary主鍵 create ...

ORACLE開發注意事項

1 自測應嚴格 2 若欄位col1由源表若干字段依據公式計算而來,col2由col1計算而來,則計算col1的結果不應先保留小數字,否則會造成col2的計算有誤差,應只在最後的結果中保留小數字。3 取源表增量部分資料時,要取全,把所有受影響的 參與計算的資料都取出來。3 關聯提取,主鍵來自一張表ta...

Oracle安裝注意事項

筆者在安裝oracle 11g過程中,遇到過很多問題,總結了一些可能有用的注意事項,如下 1.安裝之前關防火牆 2.管理員執行cmd,輸入 set oracle unqname orcl 這是後面會用到的資料庫名 3.管理員許可權執行setup.exe setup.exe是oracle的安裝檔案 4...