Oracle常用指令碼記錄,方便以後使用
Oracle常用指令碼記錄,方便以後使用:
lock:check lock info
col spid format a10
col inst_id format a7
col owner format a15
col object_name format a20
col machine format a30
col program format a20
select pr.spid,se.inst_id,se.sid,se.serial#,ob.owner,ob.object_name,se.osuser,se.machine,se.terminal,se.program
,gvl1.ctime,(select count(*)-1 from gv$lock where inst_id=gvl2.inst_id and id1=gvl2.id1) as blocking_session,
trunc(gvl2.id1/power(2,16)) xidusn,bitand(gvl2.id1,to_number('ffff','xxxx')) xidslot,gvl2.id2 xidsqn
from gv$lock gvl1,gv$session se,dba_objects ob ,gv$process pr,
(select * from gv$lock where block=1) gvl2
where gvl1.inst_id=gvl2.inst_id and gvl1.sid=gvl2.sid and gvl1.type='TM'
and gvl1.inst_id=se.inst_id and gvl1.sid=se.sid and gvl1.id1=ob.object_id
and se.paddr=pr.addr;
actsess:check active session
select count(*) count from v$session where status='ACTIVE';
sp:check tablespace usage info
set pagesize 100
set timing on
select * from
(select x.tablespace_name,x.contents,x.status,x.extent_management,x.all_bytes/1024/1024 "ALL_SIZE(MB)",y.free_bytes/1024/1024 "FREE_SIZE(MB)",
(x.all_bytes-y.free_bytes)/1024/1024 "USED_SIZE(MB)",round((x.all_bytes-y.free_bytes)/x.all_bytes,4)*100 USAGE
from (select ts.tablespace_name,ts.contents,ts.status,ts.extent_management,sum(bytes) all_bytes from
dba_tablespaces ts, dba_data_files dbf
where ts.tablespace_name=dbf.tablespace_name group by ts.tablespace_name,ts.contents,ts.status,ts.extent_management) x,
(select tablespace_name,sum(bytes) free_bytes from dba_free_space fs group by tablespace_name) y
where x.tablespace_name=y.tablespace_name
union all
select h.tablespace_name,'TEMPORARY' contents,f.status,'LOCAL',sum(h.bytes_free+h.bytes_used)/1024/1024 "ALL_SIZE(MB)",sum((h.bytes_free+h.bytes_used-nvl(p.bytes_used,0)))/1024/1024 "FREE_SIZE(MB)",
sum(p.bytes_used)/1024/1024 "USED_SIZE(MB)",round(sum(p.bytes_used)/sum(h.bytes_free+h.bytes_used),4)*100 USAGE
from v$temp_space_header h,v$temp_extent_pool p,dba_temp_files f
where h.file_id=p.file_id(+) and h.file_id=f.file_id
group by h.tablespace_name,f.status)
order by 8 desc;
select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') systime from dual;
yccs:select hide parameter info
set linesize 160
col ksppinm format a40
col ksppstvl format a30
col ksppdesc format a190
SELECT ksppinm, ksppstvl, ksppdesc
FROM x$ksppi x, x$ksppcv y
WHERE x.indx = y.indx
AND ksppinm like '%&value%';
tsp:check temp tablespace usage
select y.name,y.bytes/1024/1024 total_mb,(x.total_blocks*y.block_size)/1024/1024 used_mb,(y.bytes-x.total_blocks*y.block_size)/1024/1024 free_mb,
round((x.total_blocks*y.block_size)/y.bytes,4)*100 pct
from v$sort_segment x,(
select b.name,sum(a.bytes) bytes,a.block_size from v$tempfile a,v$tablespace b
where a.ts#=b.ts# group by b.name,a.block_size) y
where x.tablespace_name=y.name;
lock:check lock info
col spid format a10
col inst_id format a7
col owner format a15
col object_name format a20
col machine format a30
col program format a20
select pr.spid,se.inst_id,se.sid,se.serial#,ob.owner,ob.object_name,se.osuser,se.machine,se.terminal,se.program
,gvl1.ctime,(select count(*)-1 from gv$lock where inst_id=gvl2.inst_id and id1=gvl2.id1) as blocking_session,
trunc(gvl2.id1/power(2,16)) xidusn,bitand(gvl2.id1,to_number('ffff','xxxx')) xidslot,gvl2.id2 xidsqn
from gv$lock gvl1,gv$session se,dba_objects ob ,gv$process pr,
(select * from gv$lock where block=1) gvl2
where gvl1.inst_id=gvl2.inst_id and gvl1.sid=gvl2.sid and gvl1.type='TM'
and gvl1.inst_id=se.inst_id and gvl1.sid=se.sid and gvl1.id1=ob.object_id
and se.paddr=pr.addr;
actsess:check active session
select count(*) count from v$session where status='ACTIVE';
sp:check tablespace usage info
set pagesize 100
set timing on
select * from
(select x.tablespace_name,x.contents,x.status,x.extent_management,x.all_bytes/1024/1024 "ALL_SIZE(MB)",y.free_bytes/1024/1024 "FREE_SIZE(MB)",
(x.all_bytes-y.free_bytes)/1024/1024 "USED_SIZE(MB)",round((x.all_bytes-y.free_bytes)/x.all_bytes,4)*100 USAGE
from (select ts.tablespace_name,ts.contents,ts.status,ts.extent_management,sum(bytes) all_bytes from
dba_tablespaces ts, dba_data_files dbf
where ts.tablespace_name=dbf.tablespace_name group by ts.tablespace_name,ts.contents,ts.status,ts.extent_management) x,
(select tablespace_name,sum(bytes) free_bytes from dba_free_space fs group by tablespace_name) y
where x.tablespace_name=y.tablespace_name
union all
select h.tablespace_name,'TEMPORARY' contents,f.status,'LOCAL',sum(h.bytes_free+h.bytes_used)/1024/1024 "ALL_SIZE(MB)",sum((h.bytes_free+h.bytes_used-nvl(p.bytes_used,0)))/1024/1024 "FREE_SIZE(MB)",
sum(p.bytes_used)/1024/1024 "USED_SIZE(MB)",round(sum(p.bytes_used)/sum(h.bytes_free+h.bytes_used),4)*100 USAGE
from v$temp_space_header h,v$temp_extent_pool p,dba_temp_files f
where h.file_id=p.file_id(+) and h.file_id=f.file_id
group by h.tablespace_name,f.status)
order by 8 desc;
select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') systime from dual;
yccs:select hide parameter info
set linesize 160
col ksppinm format a40
col ksppstvl format a30
col ksppdesc format a190
SELECT ksppinm, ksppstvl, ksppdesc
FROM x$ksppi x, x$ksppcv y
WHERE x.indx = y.indx
AND ksppinm like '%&value%';
tsp:check temp tablespace usage
select y.name,y.bytes/1024/1024 total_mb,(x.total_blocks*y.block_size)/1024/1024 used_mb,(y.bytes-x.total_blocks*y.block_size)/1024/1024 free_mb,
round((x.total_blocks*y.block_size)/y.bytes,4)*100 pct
from v$sort_segment x,(
select b.name,sum(a.bytes) bytes,a.block_size from v$tempfile a,v$tablespace b
where a.ts#=b.ts# group by b.name,a.block_size) y
where x.tablespace_name=y.name;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2134361/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 常用的方便指令
- 某系統架構方案,記錄一下,方便以後的學習!架構
- oracle pga使用情況常用指令碼:Oracle指令碼
- 記錄 react的常用指令React
- 把PHP大牛記下來,方便以後關注PHP
- 以後要看的原始碼,先記錄一下原始碼
- ORACLE常用SQL指令碼2OracleSQL指令碼
- 暫時記錄,以後歸檔。
- 匯出oracle表記錄為insert指令碼Oracle指令碼
- Oracle DBA常用監控指令碼Oracle指令碼
- 常用的Oracle指令碼參考Oracle指令碼
- 6 個方便的 Git 指令碼Git指令碼
- MySQL 常用命令列指令(個人記錄)MySql命令列
- ORACLE常用定時備份指令碼Oracle指令碼
- Oracle 效能相關常用指令碼(SQL)Oracle指令碼SQL
- ORACLE DBA常用語句和指令碼Oracle指令碼
- Linux使用者登入記錄分析指令碼Linux指令碼
- 使用jmeter錄製web指令碼JMeterWeb指令碼
- mysql 修改data目錄後 無法使用指令碼啟動薦MySql指令碼
- 一鍵部署lamp指令碼記錄LAMP指令碼
- 常用指令碼指令碼
- oracle DBA 常用監控指令碼1(轉)Oracle指令碼
- ORACLE一些不常用的指令碼Oracle指令碼
- 【管理】Oracle 常用的V$ 檢視指令碼Oracle指令碼
- 將自己最常用的一些指令碼放上來,這樣方便查詢指令碼
- oracle_ray.sh 常用的oracle sql功能指令碼OracleSQL指令碼
- 記錄一個防止DDL的指令碼指令碼
- ORACLE DBA常用SQL指令碼工具->管理篇(zt)OracleSQL指令碼
- 錄屏方法剖析,記錄指令碼跑測不再難指令碼
- SQLServer 常用指令碼SQLServer指令碼
- MySQL 常用指令碼MySql指令碼
- dba常用指令碼指令碼
- 常用指令碼-02指令碼
- 常用shell指令碼指令碼
- 【NFS】Linux配置NFS共享常用SQL指令碼目錄NFSLinuxSQL指令碼
- tmux指令記錄UX
- ecs使用指令碼安裝oracle指令碼Oracle
- Robot Framework(8)——指令碼語法示例記錄Framework指令碼