Oracle通過shell指令碼查看procedure的資訊

來源:互聯網
上載者:User

Oracle通過shell指令碼查看procedure的資訊

在一個schema中,可能含有大量的procedure, 有時候想查看具體的資訊,一般得通過toad,plsql dev等工具來查看,有時候在儘可能擺脫圖形工具的前提下,想能夠儘快的尋找一些資訊,還是使用shell指令碼更快,更准,更直接。

 可以使用如下的shell指令碼來尋找procedure的資訊。
 以下的指令碼可以尋找是否有需要的prcedure資訊。

PROC_OWNER=`sqlplus -silent $DB_CONN_STR@$SH_DB_SID <<END
 set pagesize 40 feedback off verify off heading on echo off
 col owner format a20
 col object_name format a30
 set linesize 150
 select owner, object_name,object_id,object_type,aggregate,pipelined,parallel,interface,deterministic,authid from dba_procedures
 where owner=upper('$1')  and  object_type='PROCEDURE' and object_name like '%'||upper('$2')||'%'
 /
 exit;
 END`

if [ -z "$PROC_OWNER" ]; then
  echo "no object exists, please check again"
  exit 0
 else
  echo '*******************************************'
  echo " $PROC_OWNER    "
  echo '*******************************************'
 fi

以下的指令碼可以查看對應的procedure資訊

PROC_OWNER=`sqlplus -silent $DB_CONN_STR@$SH_DB_SID <<END
 set pagesize 40 feedback off verify off heading on echo off
 col owner format a20
 col object_name format a30
 set linesize 150
 select owner, object_name,object_id,object_type,aggregate,pipelined,parallel,interface,deterministic,authid from dba_procedures
 where owner=upper('$1')  and  object_type='PROCEDURE' and object_name like '%'||upper('$2')||'%'
 /
 exit;
 END`

if [ -z "$PROC_OWNER" ]; then
  echo "no object exists, please check again"
  exit 0
 else
  echo '*******************************************'
  echo " $PROC_OWNER    "
  echo '*******************************************'
 fi


指令碼啟動並執行結果如下:

[ora11g@rac1 dbm_lite]$ ksh findproc.sh n1
 *******************************************
 
 OWNER                OBJECT_NAME                    OBJECT_ID OBJECT_TYPE  AGG PIP PAR INT DET AUTHID
 -------------------- ------------------------------ ---------- ------------- --- --- --- --- --- ------------
 N1                  TEST_DUMP_CSV                      15163 PROCEDURE    NO  NO  NO  NO  NO  DEFINER   
 *******************************************
 [ora11g@rac1 dbm_lite]$ ksh showproc.sh n1 test_dmp_csv
 no object exists, please check again

 [ora11g@rac1 dbm_lite]$ ksh showproc.sh n1 test_dump_csv
 *******************************************
 
 OWNER                OBJECT_NAME                    OBJECT_ID OBJECT_TYPE  AGG PIP PAR INT DET AUTHID
 -------------------- ------------------------------ ---------- ------------- --- --- --- --- --- ------------
 N1                  TEST_DUMP_CSV                      15163 PROCEDURE    NO  NO  NO  NO  NO  DEFINER   
 *******************************************
 .
 procedure test_dump_csv
 as
    l_rows  number;
 begin
    l_rows := dump_csv( 'select *
                            from t
                            ',
                        ',', '/tmp', 'test.dat' );
 end;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.