知识大全 DBA 常用Scripts(第一部分)

Posted

篇首语:读和写是学生最必要的两种学习方法,也是通向周围世界的两扇窗口。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 DBA 常用Scripts(第一部分)相关的知识,希望对你有一定的参考价值。

Oracle DBA 常用Scripts(第一部分)!  以下文字资料是由(历史新知网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

  以下是我在一些网站上一点点节选出来的!我还会继续整理!先来一部分!大家觉得好 我会在贴!   网站太多了请到各网站的索引都有!   Oracle DBA 常用 Script    Description: This script will display the active user   and the rollback segment being used in the database   Code:   column rr heading RB Segment format a   column us heading Username format a   column os heading OS User format a   column te heading Terminal format a     SELECT r name rr   nvl(s username no transaction ) us   s osuser os   s terminal te   FROM   v$lock l   v$session s   v$rollname r   WHERE   l sid = s sid(+) AND   trunc(l id / ) = r usn AND   l type = TX AND   l lmode =   ORDER BY r name   /    Description: When you connect to sqlplus you see the the following sql prompt SQL>   By using this sql in the glogin sql you will see a prompt similar to the following:   SCOTT@DB >   Code:     The following code works on Oracle i ( )   You have to insert the following line of code in glogin sql which is usually found in   $ORACLE_HOME/sqlplus/admin     set termout off   set echo off   define X=NotConnected   define Y=DBNAME     Column Usr New_Value X   Column DBName New_Value Y   Select SYS_CONTEXT( USERENV SESSION_USER ) Usr From Dual;      The following does not work in but works in or above   Select SYS_CONTEXT( USERENV DB_NAME ) DBNAME From Dual;      If you are using use this   Select Global_Name DBNAME from Global_Name;     set termout on   set sqlprompt &X@&Y>     Please note that this method will work only when you make a new sql plus session because when you make a new sql plus session then only glogin sql is executed    Description: I got sick and tired of not having biise functions for numbers in Oracle so I went ahead and wrote my own   Code:     CREATE OR REPLACE PACKAGE biise IS   FUNCTION hexconverter (pi_number IN NUMBER)   RETURN CHAR;     FUNCTION hexconverter (pi_hexstr IN CHAR)   RETURN NUMBER;     FUNCTION bitand (pi_num IN NUMBER pi_num IN NUMBER)   RETURN NUMBER;     FUNCTION bitor (pi_num IN NUMBER pi_num IN NUMBER)   RETURN NUMBER;     FUNCTION bitxor (pi_num IN NUMBER pi_num IN NUMBER)   RETURN NUMBER;   END biise;   /     CREATE OR REPLACE PACKAGE BODY biise   IS   FUNCTION numtohexchar (pi_number IN NUMBER)   RETURN CHAR   IS   v_hextoreturn CHAR ( );   BEGIN   IF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := ;   ELSIF pi_number = THEN   v_hextoreturn := A ;   ELSIF pi_number = THEN   v_hextoreturn := B ;   ELSIF pi_number = THEN   v_hextoreturn := C ;   ELSIF pi_number = THEN   v_hextoreturn := D ;   ELSIF pi_number = THEN   v_hextoreturn := E ;   ELSIF pi_number = THEN   v_hextoreturn := F ;   ELSE   raise_application_error ( Invalid value TRUE);   END IF;     RETURN v_hextoreturn;   END numtohexchar;     FUNCTION hexchartonum (pi_hexchar IN CHAR)   RETURN NUMBER   IS   v_numtoreturn NUMBER ( );   BEGIN   IF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = THEN   v_numtoreturn := ;   ELSIF pi_hexchar = A THEN   v_numtoreturn := ;   ELSIF pi_hexchar = B THEN   v_numtoreturn := ;   ELSIF pi_hexchar = C THEN   v_numtoreturn := ;   ELSIF pi_hexchar = D THEN   v_numtoreturn := ;   ELSIF pi_hexchar = E THEN   v_numtoreturn := ;   ELSIF pi_hexchar = F THEN   v_numtoreturn := ;   ELSE   raise_application_error ( Invalid value TRUE);   END IF;     RETURN v_numtoreturn;   END hexchartonum;     FUNCTION hexconverter (pi_number IN NUMBER)   RETURN CHAR   IS   i NUMBER;   v_digit NUMBER ( );   v_hexstr VARCHAR ( );   BEGIN   v_hexstr := ;   FOR i IN REVERSE   LOOP   v_digit := MOD (TRUNC (pi_number / POWER ( i)) );   v_hexstr := v_hexstr || numtohexchar (v_digit);   END LOOP;     RETURN v_hexstr;   END hexconverter;     FUNCTION hexconverter (pi_hexstr IN CHAR)   RETURN NUMBER   IS   i NUMBER;   v_digit NUMBER ( );   v_numtoreturn NUMBER;   v_hexstr CHAR ( );   BEGIN   v_hexstr := LPAD (pi_hexstr );   v_numtoreturn := ;     FOR i IN   LOOP   V_digit := hexchartonum (SUBSTR (v_hexstr i ));   v_numtoreturn := v_numtoreturn + v_digit * POWER ( i);   END LOOP;     RETURN v_numtoreturn;   END hexconverter;     FUNCTION bitand (pi_num IN NUMBER pi_num IN NUMBER)   RETURN NUMBER   IS   v_hex CHAR ( );   v_hex CHAR ( );   v_raw RAW ( );   v_raw RAW ( );   v_rawresult RAW ( );   v_hexresult VARCHAR ( );   v_numresult NUMBER;   BEGIN   v_hex := hexconverter (pi_num );   v_hex := hexconverter (pi_num );   v_raw := HEXTORAW (v_hex );   v_raw := HEXTORAW (v_hex );   v_rawresult := UTL_RAW bit_and (v_raw v_raw );   v_hexresult := RAWTOHEX (v_rawresult);   v_numresult := hexconverter (v_hexresult);   RETURN v_numresult;   END bitand;     FUNCTION bitor (pi_num IN NUMBER pi_num IN NUMBER)   RETURN NUMBER   IS   v_hex CHAR ( );   v_hex CHAR ( );   v_raw RAW ( );   v_raw RAW ( );   v_rawresult RAW ( );   v_hexresult VARCHAR ( );   v_numresult NUMBER;   BEGIN   v_hex := hexconverter (pi_num );   v_hex := hexconverter (pi_num );   v_raw := HEXTORAW (v_hex );   v_raw := HEXTORAW (v_hex );   v_rawresult := UTL_RAW bit_or (v_raw v_raw );   v_hexresult := RAWTOHEX (v_rawresult);   v_numresult := hexconverter (v_hexresult);   RETURN v_numresult;   END bitor;     FUNCTION bitxor (pi_num IN NUMBER pi_num IN NUMBER)   RETURN NUMBER   IS   v_hex CHAR ( );   v_hex CHAR ( );   v_raw RAW ( );   v_raw RAW ( );   v_rawresult RAW ( );   v_hexresult VARCH cha138/Article/program/Oracle/201311/16529

相关参考

知识大全 DBA常用脚本2-性能监控

DBA常用脚本2-性能监控  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  数据缓冲区的命中率已经

知识大全 ORACLE DBA常用SQL脚本工具-管理篇(1)

ORACLEDBA常用SQL脚本工具-管理篇(1)  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 

知识大全 Data Server Scripts

DataServerScripts  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  Sortofo

知识大全 DBA必须熟悉的、最有用的DBA视图

DBA必须熟悉的、最有用的DBA视图  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  DBA必须熟

知识大全 ORACLE之常用FAQ V1.0

ORACLE之常用FAQV1.0  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  第一部分SQL&

知识大全 sql server dba 面试笔试问题

很多开发人员都想成为一名DBA也有很多人一开始就把自己定位成为一名DBADBA究竟需要掌握些什么知识和技能呢?以下是我做DBA工作和面试DBA时整理的一些DBA方面的三十个问题三十个大问题中还有许多小

知识大全 DBA袖珍指南

管理Oracle9i:DBA袖珍指南  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  Oracle

知识大全 让我们一起学做业余DBA

让我们一起学做业余DBA!  以下文字资料是由(历史新知网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  前言  这篇文章介绍了DBA每

知识大全 Oracle DBA需要的技能

OracleDBA需要的技能  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  dba掌握的技术  

知识大全 如何成为一名Oracle应用DBA

如何成为一名Oracle应用DBA  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!从一个普通的Ora