匯出oracle資料庫預存程序

來源:互聯網
上載者:User
oracle|預存程序|資料|資料庫

項目結束了,想把自己寫的預存程序匯出儲存一份就寫了這麼一個簡單的指令碼,拿出來給大家共用一下。其實很簡單,主要用到user_procedures、user_source兩個視圖,大家一看就知道了。

好像網上搜到的一些都不夠全面,而且零零散散,如果覺得好的話就支援一下吧,'

#! /usr/bin/ksh
. ~/.profile

beginTime=` date +%Y年%m月%d日%H時%M分%S秒 `


bindir=~/work/common
prodir=~/work/common/procedure

#串連資料庫(帶參數-S)
ORA_S()
{
~/cfg/dbetl_S
}

#串連資料庫(不帶參數)
ORA()
{
~/cfg/dbetl
}

#獲得預存程序名稱
getProcedureName()
{
ORA_S <<! >${bindir}/procedure.lst

set heading off;
SET FEEDBACK OFF;
set pagesize 0 ;
set wrap off;
set echo off;
set term off;
set linesize 1000;
set trimspool on;

select object_name from user_procedures;

exit
!

}

#匯出預存程序代碼
exportProcedureSource()
{
ORA_S <<!   >${prodir}/${procedure_name}.sql

set serveroutput on;
set heading off;
SET FEEDBACK OFF;
set pagesize 0 ;
set wrap off;
set echo off;
set term off;
set linesize 1000;
set trimspool on;

select text from user_source a where a.name = '${procedure_name}' order by a.line;

exit
!

}


#####################        mian         ##########################

getProcedureName

mkdir prodir

while read procedure_name
do

    exportProcedureSource

done<${bindir}/procedure.lst


echo "begin at ${beginTime}"
echo "end   at ` date +%Y年%m月%d日%H時%M分%S秒 `"


 



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.