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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 常用的方便指令
- 記錄 react的常用指令React
- ORACLE常用定時備份指令碼Oracle指令碼
- oracle_ray.sh 常用的oracle sql功能指令碼OracleSQL指令碼
- 6 個方便的 Git 指令碼Git指令碼
- 使用jmeter錄製web指令碼JMeterWeb指令碼
- MySQL 常用命令列指令(個人記錄)MySql命令列
- 指令記錄
- oracle 資料庫徹底清除目錄指令碼Oracle資料庫指令碼
- 一個方便 LeetCode 複習的指令碼LeetCode指令碼
- MySQL 常用指令碼MySql指令碼
- 常用shell指令碼指令碼
- SQLServer 常用指令碼SQLServer指令碼
- python 常用指令碼Python指令碼
- 錄屏方法剖析,記錄指令碼跑測不再難指令碼
- tmux指令記錄UX
- Robot Framework(8)——指令碼語法示例記錄Framework指令碼
- linux mysql定時備份指令碼記錄LinuxMySql指令碼
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- 常用指令碼學習手冊——Bat指令碼指令碼BAT
- Bash 常用指令碼片段指令碼
- oracle建庫指令碼Oracle指令碼
- ORACLE備份指令碼Oracle指令碼
- 常用CDN記錄
- Oracle 常用SQL筆記OracleSQL筆記
- 【隨手記錄】mongoDB離線安裝指令碼MongoDB指令碼
- Oracle 建立表空間和使用者指令碼Oracle指令碼
- golang常用庫:日誌記錄庫-logrus使用Golang
- JMeter錄製指令碼JMeter指令碼
- Jmeter —— 錄製指令碼JMeter指令碼
- linux常用的shell指令碼Linux指令碼
- sqlmap常用繞過指令碼SQL指令碼
- linux 常用Mysql指令碼命令LinuxMySql指令碼
- MHA常用指令碼簡介指令碼
- 個人常用記錄
- linux常用操作記錄Linux
- nginx 常用配置記錄Nginx
- Conda常用命令記錄(自用記錄)
- 使用ogg 從oracle 同步mysql遇到問題記錄OracleMySql