Oracle基本資訊檢查
1. 檢查Windows下的Oracle相關服務的狀態
主要服務包括: OracleServiceORA10:Oracle例項服務
OracleOraDb10g_home1TNSListenerFslmyoracle: Oracle監聽服務(OFS管理)
OracleMSCSServices:Oracle Fail Safe for MSCS服務
在當前活動節點上,服務狀態應該是正常“已啟動”狀態。
2. 檢查Oracle初始化引數
- select * from v$parameter;
select * from v$parameter;
3. 檢查Oracle的例項狀態
- select instance_name,version,status,database_status
- from v$instance;
select instance_name,version,status,database_status from v$instance;其中"STATUS"表示Oracle當前的例項狀態,必須為"OPEN";"DATABASE_STATUS"表示Oracle當前資料庫的狀態,必須為"ACTIVE"。
4. 檢查後臺執行緒的狀態
- Select name,Description
- From V$BGPROCESS
- Where Paddr<>'00';
Select name,Description From V$BGPROCESS Where Paddr<>'00';
5. 檢查系統全域性區SGA資訊
- select * from v$sga;
select * from v$sga;檢查SGA各部份的分配情況,與實際記憶體比較是否合理。
6. 檢查SGA各部分佔用記憶體狀況
- select * from v$sgastat;
select * from v$sgastat;檢查有無佔用大量Shared pool的物件,及是否有記憶體浪費情況。
7. 檢查系統SCN號
- select dbms_flashback.get_system_change_number from dual;
- select current_scn from v$database;
select dbms_flashback.get_system_change_number from dual; select current_scn from v$database;
8. 檢查資料庫狀態
- select name,log_mode,open_mode from v$database;
select name,log_mode,open_mode from v$database;
9. 檢查當前資料庫的作業系統平臺
- select platform_name from v$database;
select platform_name from v$database;
10. 檢查資料庫的大小,和空間使用情況
- col tablespace format a20
- select b.file_id 檔案ID,
- b.tablespace_name 表空間,
- b.file_name 物理檔名,
- b.bytes 總位元組數,
- (b.bytes-sum(nvl(a.bytes,0))) 已使用,
- sum(nvl(a.bytes,0)) 剩餘,
- sum(nvl(a.bytes,0))/(b.bytes)*100 剩餘百分比
- from dba_free_space a,dba_data_files b
- where a.file_id=b.file_id
- group by b.tablespace_name,b.file_name,b.file_id,b.bytes
- order by b.tablespace_name
- /
col tablespace format a20 select b.file_id 檔案ID, b.tablespace_name 表空間, b.file_name 物理檔名, b.bytes 總位元組數, (b.bytes-sum(nvl(a.bytes,0))) 已使用, sum(nvl(a.bytes,0)) 剩餘, sum(nvl(a.bytes,0))/(b.bytes)*100 剩餘百分比 from dba_free_space a,dba_data_files b where a.file_id=b.file_id group by b.tablespace_name,b.file_name,b.file_id,b.bytes order by b.tablespace_name /dba_free_space --表空間剩餘空間狀況
dba_data_files --資料檔案空間佔用情況
11. 檢查資料庫的建立日期和歸檔方式
- Select Created, Log_Mode, Log_Mode From V$Database;
Select Created, Log_Mode, Log_Mode From V$Database;
12. 檢查資料庫是否處於歸檔模式,並啟動了自動歸檔程式
- archive log list;
archive log list;
13. 檢查NLS資訊(包括字符集)
- select * from nls_database_parameters
select * from nls_database_parameters'NLS_LANGUAGE' || 'NLS_TERRITORY' || 'NLS_CHARACTERSET' 即字符集。
14. 檢查表空間的名稱、狀態及大小
- select t.tablespace_name, t.status, round(sum(bytes/(1024*1024)),0) ts_size
- from dba_tablespaces t, dba_data_files d
- where t.tablespace_name = d.tablespace_name
- group by t.tablespace_name, t.status;
select t.tablespace_name, t.status, round(sum(bytes/(1024*1024)),0) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name, t.status;
15. 檢查每個表空間佔用空間的大小
- Select Tablespace_Name,Sum(bytes)/1024/1024
- From Dba_Segments Group By Tablespace_Name;
Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name;
16. 檢查表空間物理檔案的名稱及大小
- select tablespace_name, file_id, file_name,
- round(bytes/(1024*1024),0) total_space
- from dba_data_files
- order by tablespace_name;
select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name;
17. 查詢表空間的剩餘大小
- select tablespace_name,sum(bytes)/(1024*1024) as free_space
- from dba_free_space
- group by tablespace_name;
select tablespace_name,sum(bytes)/(1024*1024) as free_space from dba_free_space group by tablespace_name;
18. 檢查表空間的使用情況
- SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
- (B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
- FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
- WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME
- AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE, (B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE" FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
19. 檢查表空間碎塊狀況
- col tablespace_name form a25
- select tablespace_name, count(*) chunks,
- max(bytes)/1024/1024 max_chunk,
- sum(bytes)/1024/1024 total_space
- from dba_free_space group by tablespace_name;
col tablespace_name form. a25 select tablespace_name, count(*) chunks, max(bytes)/1024/1024 max_chunk, sum(bytes)/1024/1024 total_space from dba_free_space group by tablespace_name;如果最大可用塊(max_chunk)與總大小(total_space)相比太小,要考慮接合表空間碎片或重建某些資料庫物件。 碎片接合的方法: alter tablespace 表空間名 coalesce;
20. 檢查回滾段名稱、狀態及大小
- select segment_name, tablespace_name, r.status,
- (initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent,
- max_extents, v.curext CurExtent
- From dba_rollback_segs r, v$rollstat v
- Where r.segment_id = v.usn(+)
- order by segment_name ;
select segment_name, tablespace_name, r.status, (initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent, max_extents, v.curext CurExtent From dba_rollback_segs r, v$rollstat v Where r.segment_id = v.usn(+) order by segment_name ;
21. 檢查控制檔案狀態
- select * from v$controlfile;
select * from v$controlfile;
22. 檢查日誌檔案狀態
- select * from v$logfile;
select * from v$logfile;
23. 檢查日誌組資訊
- select * from v$log;
select * from v$log;
24. 檢查資料檔案狀態
- select file_name,status
- from dba_data_files;
select file_name,status from dba_data_files;
25. 檢查資料檔案存放路徑
- col file_name format a50
- select tablespace_name,file_id,bytes/1024/1024,file_name
- from dba_data_files order by file_id;
col file_name format a50 select tablespace_name,file_id,bytes/1024/1024,file_name from dba_data_files order by file_id;
26. 檢查資料檔案的自動增長控制
- select file_name,autoextensible from dba_data_files;
select file_name,autoextensible from dba_data_files;
27. 檢查臨時資料檔案路徑
- select file_name
- from Dba_temp_files;
select file_name from Dba_temp_files;
28. 檢查閃回恢復區的路徑
- select name from v$recovery_file_dest;
select name from v$recovery_file_dest;
29. 檢查資料庫庫物件
- select owner, object_type, status, count(*) count#
- from all_objects group by owner, object_type, status;
select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;
30. 檢查資料庫的版本
- Select version FROM Product_component_version
- Where SUBSTR(PRODUCT,1,6)='Oracle';
- VERSION
- ---------------
- 11.1.0.6.0
Select version FROM Product_component_version Where SUBSTR(PRODUCT,1,6)='Oracle'; VERSION --------------- 11.1.0.6.0依次為:版本號11、新特性版本號1、維護版本號0、普通的補丁設定號碼6、特殊的平臺補丁設定號碼0
31. 檢查資料庫的建立日期和歸檔方式
- Select Created, Log_Mode, Log_Mode From V$Database;
Select Created, Log_Mode, Log_Mode From V$Database;
32. 檢查當前所有物件
- select * from tab;
select * from tab;
33. 檢查當前連線使用者
- show user;
show user;
34. 檢查已有使用者:
- select username from dba_users;
select username from dba_users;
35. 檢查所有表、索引、儲存過程、觸發器、包等物件的狀態
- select owner,object_name,object_type
- from dba_objects where status!='VALID'
- and owner!='SYS' and owner!='SYSTEM';
select owner,object_name,object_type from dba_objects where status!='VALID' and owner!='SYS' and owner!='SYSTEM';
36. 檢查當前使用者的預設表空間、臨時表空間
- select username,default_tablespace, temporary_tablespace from user_users;
select username,default_tablespace, temporary_tablespace from user_users;
37. 檢查當前使用者的角色
- select * from user_role_privs;
select * from user_role_privs;
38. 檢查當前使用者的系統許可權和表級許可權
- select * from user_sys_privs;
- select * from user_tab_privs;
select * from user_sys_privs; select * from user_tab_privs;
39. 檢查使用者下所有的表
- select * from user_tables;
select * from user_tables;
40. 檢查各個表的大小
檢查當前使用者每個表佔用空間的大小:
- Select Segment_Name,Sum(bytes)/1024/1024
- From User_Extents Group By Segment_Name
Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name注:段名即表名
按資料物件大小排序
- Select Segment_Name,segment_type, Sum(bytes)/1024/1024 as MB
- From User_Extents
- Group By Segment_Name, segment_type
- Order by MB
Select Segment_Name,segment_type, Sum(bytes)/1024/1024 as MB From User_Extents Group By Segment_Name, segment_type Order by MB
41. 檢查某表的建立時間
- select object_name,created from user_objects where object_name=upper('&table_name');
select object_name,created from user_objects where object_name=upper('&table_name');
42. 檢查名稱包含log字元的表
- select object_name,object_id from user_objects
- where instr(object_name,'LOG')>0;
select object_name,object_id from user_objects where instr(object_name,'LOG')>0;
43. 檢查某表的大小
- select sum(bytes)/(1024*1024) as "size(M)" from user_segments
- where segment_name=upper('&table_name');
select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&table_name');
44. 檢查放在記憶體區裡的表
- select table_name,cache from user_tables where instr(cache,'Y')>0;
select table_name,cache from user_tables where instr(cache,'Y')>0;
45. 檢查索引個數和類別
- select index_name,index_type,table_name from user_indexes order by table_name;
select index_name,index_type,table_name from user_indexes order by table_name;
46. 檢查索引中被索引的欄位
- select * from user_ind_columns where index_name=upper('&index_name');
select * from user_ind_columns where index_name=upper('&index_name');
47. 檢查索引的大小
- select sum(bytes)/(1024*1024) as "size(M)" from user_segments
- where segment_name=upper('&index_name');
select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&index_name');
48. 檢查是否有失效的索引
- select index_name, owner, table_name, tablespace_name
- from dba_indexes
- where owner not in ('SYS','SYSTEM') and status != 'VALID';
select index_name, owner, table_name, tablespace_name from dba_indexes where owner not in ('SYS','SYSTEM') and status != 'VALID';如果有記錄返回,考慮重建這些索引。
49. 檢查是否有無效的物件
- select object_name, object_type, owner, status
- from dba_objects
- where status !='VALID'
- and owner not in ('SYS','SYSTEM')
- and object_type in ('TRIGGER','VIEW','PROCEDURE','FUNCTION');
select object_name, object_type, owner, status from dba_objects where status !='VALID' and owner not in ('SYS','SYSTEM') and object_type in ('TRIGGER','VIEW','PROCEDURE','FUNCTION');如果存在無效的物件,手工重新編譯一下。
50. 檢查序列號
- select * from user_sequences;
select * from user_sequences;last_number是當前值
51. 檢查序列號的使用
- select sequence_owner, sequence_name, min_value,
- max_value, increment_by, last_number,
- cache_size, cycle_flag from dba_sequences;
select sequence_owner, sequence_name, min_value, max_value, increment_by, last_number, cache_size, cycle_flag from dba_sequences;檢查是否存在即將達到max_value的sequence 。
52. 檢查檢視的名稱
- select view_name from user_views;
select view_name from user_views;
53. 檢查建立檢視的select語句
- set view_name,text_length from user_views;
- set long 2000; --說明:可以根據檢視的text_length值設定set long 的大小
- select text from user_views where view_name=upper('&view_name');
set view_name,text_length from user_views; set long 2000; --說明:可以根據檢視的text_length值設定set long 的大小 select text from user_views where view_name=upper('&view_name');
54. 檢查同義詞的名稱
- select * from user_synonyms;
select * from user_synonyms;
55. 檢查某表的約束條件
- select constraint_name, constraint_type,search_condition, r_constraint_name
- from user_constraints where table_name = upper('&table_name');
- select c.constraint_name,c.constraint_type,cc.column_name
- from user_constraints c,user_cons_columns cc
- where c.owner = upper('&table_owner') and c.table_name = upper('&table_name')
- and c.owner = cc.owner and c.constraint_name = cc.constraint_name
- order by cc.position;
select constraint_name, constraint_type,search_condition, r_constraint_name from user_constraints where table_name = upper('&table_name'); select c.constraint_name,c.constraint_type,cc.column_name from user_constraints c,user_cons_columns cc where c.owner = upper('&table_owner') and c.table_name = upper('&table_name') and c.owner = cc.owner and c.constraint_name = cc.constraint_name order by cc.position;
56. 檢查函式和過程的狀態
- select object_name,status from user_objects where object_type='FUNCTION';
- select object_name,status from user_objects where object_type='PROCEDURE';
select object_name,status from user_objects where object_type='FUNCTION'; select object_name,status from user_objects where object_type='PROCEDURE';
57. 檢查函式和過程的原始碼
- select text from all_source where owner=user and name=upper('&plsql_name');
select text from all_source where wner=user and name=upper('&plsql_name');
58. 檢查當前資料庫有幾個使用者連線
用系統管理員許可權執行,
- select username,sid,serial#, machine, status from v$session;
select username,sid,serial#, machine, status from v$session;USERNAME:建立該會話的使用者名稱;
SID:會話(session)的ID號;
SERIAL#:會話的序列號,和SID一起用來唯一標識一個會話;
PROGRAM: 這個會話是用什麼工具連線到資料庫的;
MACHINE:這個會話是從哪臺電腦連過來的
STATUS 當前這個會話的狀態,ACTIVE表示會話正在執行某些任務,INACTIVE表示當前會話沒有執行任何操作;如果要停某個連線用
- SQL> alter system kill session 'sid,serial#';
SQL> alter system kill session 'sid,serial#';如果這命令不行,找它UNIX的程式數
- SQL> select pro.spid
- from v$session ses,v$process pro
- where ses.sid=21 and ses.paddr=pro.addr;
SQL> select pro.spid from v$session ses,v$process pro where ses.sid=21 and ses.paddr=pro.addr;說明:21是某個連線的sid數
然後用 kill 命令殺此程式號。
59. 檢查定時作業的完成情況
- select job,log_user,last_date,failures
- from dba_jobs;
- select job, this_date, this_sec, next_date, next_sec, failures, what
- from dba_jobs where failures !=0 or failures is not null;
select job,log_user,last_date,failures from dba_jobs; select job, this_date, this_sec, next_date, next_sec, failures, what from dba_jobs where failures !=0 or failures is not null;如果FAILURES列是一個大於0的數的話,說明JOB執行失敗,要進一步的檢查。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8183550/viewspace-659608/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle檢視查詢慢之統計資訊收集Oracle
- oracle 基本查詢Oracle
- oracle檢視基本操作Oracle
- 從oracle v$version檢視中查詢os的資訊Oracle
- 【TUNE_ORACLE】Oracle檢查點(二)檢查點效能Oracle
- 檢視作業系統基本資訊作業系統
- Linux檢視資訊基本命令Linux
- Oracle基本檢視總結Oracle
- Oracle ASM檢視資訊OracleASM
- oracle 鎖資訊查詢
- 【TUNE_ORACLE】檢查統計資訊是否過期SQL參考OracleSQL
- oracle checkpoint檢查點Oracle
- 檢查 oracle 壞塊Oracle
- Oracle 檢查點佇列與增量檢查點Oracle佇列
- 【TUNE_ORACLE】Oracle檢查點(一)檢查點(Checkpoint)概念介紹Oracle
- Oracle10g 查詢統計資訊的一些檢視Oracle
- Oracle 檢查當前資料庫CPU和PSU補丁資訊Oracle資料庫
- Oracle完全檢查點和增量檢查點詳解Oracle
- 檢查Oracle 命中率Oracle
- oracle 常用查詢檢視Oracle
- 檢視oracle鎖相關資訊Oracle
- 【TUNE_ORACLE】Oracle檢查點(五)建立並利用Statspack定位檢查點故障Oracle
- 每秒百萬條資訊查詢 天翼雲助力江蘇核酸檢測資訊查詢
- Oracle OCP(22):查詢表資訊Oracle
- 檢查主庫dataguard有無報錯資訊的檢視
- oracle資料庫巡檢(二)全面檢查Oracle資料庫
- Oracle SCN健康狀態檢查Oracle
- 【SQL】Oracle SQL共享池檢查SQLOracle
- Oracle 檢查點涉及的SCNOracle
- oracle物理dg狀態檢查Oracle
- CUUG ORACLE檢查點講解Oracle
- [zt]Oracle檢查點ckpt (checkpoint)Oracle
- oracle檢查 小表空間Oracle
- ORACLE增量檢查點,LRBA,BWROracle
- oracle checkpoint檢查點系列一Oracle
- oracle 統計資訊檢視與收集Oracle
- Oracle檢視版本號等其他資訊Oracle
- 【SCRIPT】Oracle資料庫基本資訊收集指令碼Oracle資料庫指令碼