主頁 > 知識庫 > Oracle DBA常用語句第1/2頁

Oracle DBA常用語句第1/2頁

熱門標(biāo)簽:北京外呼系統(tǒng)公司排名 北京營銷外呼系統(tǒng)廠家 地圖標(biāo)注付款了怎么找不到了 外呼系統(tǒng)口號 外呼系統(tǒng)鄭州 貴陽智能電銷機(jī)器人官網(wǎng) 溫州人工外呼系統(tǒng) 沈陽400電話是如何辦理 百度地圖標(biāo)注員是干什么
查看表空間的名稱及大小
復(fù)制代碼 代碼如下:

SQL>select t.tablespace_name, 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;

查看表空間物理文件的名稱及大小:
復(fù)制代碼 代碼如下:

SQL>select tablespace_name, file_id, file_name,round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name;

查看回滾段名稱及大小:
復(fù)制代碼 代碼如下:

SQL>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;

如何查看某個(gè)回滾段里面,跑的什么事物或者正在執(zhí)行什么sql語句:
復(fù)制代碼 代碼如下:

SQL>select d.sql_text,a.name
from v$rollname a,v$transaction b,v$session c,v$sqltext d
where a.usn=b.xidusn and b.addr=c.taddr and c.sql_address=
d.address and c.sql_hash_value=d.hash_value
and a.usn=1;

(備注:你要看哪個(gè),就把usn=?寫成幾就行了)
查看控制文件:
SQL>select * from v$controlfile;
查看日志文件:
SQL> col member format a50
SQL>select * from v$logfile;
如何查看當(dāng)前SQL*PLUS用戶的sid和serial#:
SQL>select sid, serial#, status from v$session where audsid=userenv('sessionid');
如何查看當(dāng)前數(shù)據(jù)庫的字符集:
SQL>select userenv('language') from dual;
SQL>select userenv('lang') from dual;
怎么判斷當(dāng)前正在使用何種SQL優(yōu)化方式:
用explain plan產(chǎn)生EXPLAIN PLAN,檢查PLAN_TABLE中ID=0的POSITION列的值。
SQL>select decode(nvl(position,-1),-1,'RBO',1,'CBO') from plan_table where id=0;
如何查看系統(tǒng)當(dāng)前最新的SCN號:
SQL>select max(ktuxescnw * power(2,32) + ktuxescnb) from x$ktuxe;
在ORACLE中查找TRACE文件的腳本:
SQL>select u_dump.value || '/' || instance.value || '_ora_' ||
v$process.spid || nvl2(v$process.traceid, '_' || v$process.traceid, null ) || '.trc'"Trace File" from v$parameter u_dump cross join v$parameter instance cross join v$process join v$session on v$process.addr = v$session.paddr where u_dump.name = 'user_dump_dest' and
instance.name = 'instance_name' and v$session.audsid=sys_context('userenv','sessionid');
SQL>select d.value || '/ora_' || p.spid || '.trc' trace_file_name
from (select p.spid from sys.v_$mystat m,sys.v_$session s,
sys.v_$process p where m.statistic# = 1 and
s.sid = m.sid and p.addr = s.paddr) p,(select value from sys.v_$parameter where name ='user_dump_dest') d;
如何查看客戶端登陸的IP地址:
SQL>select sys_context('userenv','ip_address') from dual;
如何在生產(chǎn)數(shù)據(jù)庫中創(chuàng)建一個(gè)追蹤客戶端IP地址的觸發(fā)器:
復(fù)制代碼 代碼如下:

SQL>create or replace trigger on_logon_trigger
after logon on database
begin
dbms_application_info.set_client_info(sys_context('userenv', 'ip_address'));
end;
REM 記錄登陸信息的觸發(fā)器
CREATE OR REPLACE TRIGGER LOGON_HISTORY
AFTER LOGON ON DATABASE --WHEN (USER='WACOS') --ONLY FOR USER 'WACOS'
BEGIN
insert into session_history
select username,sid,serial#,AUDSID,OSUSER,ACTION,SYSDATE,null,SYS_CONTEXT('USERENV','IP_ADDRESS'),TERMINAL,machine,PROGRAM
from v$session where audsid = userenv('sessionid');
END;

查詢當(dāng)前日期:
SQL> select to_char(sysdate,'yyyy-mm-dd,hh24:mi:ss') from dual;
查看所有表空間對應(yīng)的數(shù)據(jù)文件名:
SQL>select distinct file_name,tablespace_name,AUTOEXTENSIBLE from dba_data_files;
查看表空間的使用情況:
復(fù)制代碼 代碼如下:

SQL>select sum(bytes)/(1024*1024) as free_space,tablespace_name
from dba_free_space group by tablespace_name;
SQL>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;
column tablespace_name format a18;
column Sum_M format a12;
column Used_M format a12;
column Free_M format a12;
column pto_M format 9.99;
select s.tablespace_name,ceil(sum(s.bytes/1024/1024))||'M' Sum_M,ceil(sum(s.UsedSpace/1024/1024))||'M' Used_M,ceil(sum(s.FreeSpace/1024/1024))||'M' Free_M, sum(s.UsedSpace)/sum(s.bytes) PTUSED
from (select b.file_id,b.tablespace_name,b.bytes,
(b.bytes-sum(nvl(a.bytes,0))) UsedSpace,
sum(nvl(a.bytes,0)) FreeSpace,(sum(nvl(a.bytes,0))/(b.bytes)) * 100 FreePercentRatio from sys.dba_free_space a,sys.dba_data_files b
where a.file_id(+)=b.file_id group by b.file_id,b.tablespace_name,b.bytes
order by b.tablespace_name) s group by s.tablespace_name
order by sum(s.FreeSpace)/sum(s.bytes) desc;

查看數(shù)據(jù)文件的hwm(可以resize的最小空間)和文件頭大小:
復(fù)制代碼 代碼如下:

SELECT v1.file_name,v1.file_id,
num1 totle_space,
num3 free_space,
num1-num3 "USED_SPACE(HWM)",
nvl(num2,0) data_space,
num1-num3-nvl(num2,0) file_head
FROM
(SELECT file_name,file_id,SUM(bytes) num1 FROM Dba_Data_Files GROUP BY file_name,file_id) v1,
(SELECT file_id,SUM(bytes) num2 FROM dba_extents GROUP BY file_id) v2,
(SELECT file_id,SUM(BYTES) num3 FROM DBA_FREE_SPACE GROUP BY file_id) v3
WHERE v1.file_id=v2.file_id(+)
AND v1.file_id=v3.file_id(+);

12下一頁閱讀全文
您可能感興趣的文章:
  • SQLServer 常用語句(按功能分)
  • 常用SQL語句(嵌套子查詢/隨機(jī)等等)詳細(xì)整理

標(biāo)簽:溫州 衡水 通遼 包頭 定西 淮北 潮州 衢州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle DBA常用語句第1/2頁》,本文關(guān)鍵詞  Oracle,DBA,常用,語句,第,2頁,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Oracle DBA常用語句第1/2頁》相關(guān)的同類信息!
  • 本頁收集關(guān)于Oracle DBA常用語句第1/2頁的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章