搜尋Oracle DDL中的關鍵字

zchbaby2000發表於2018-09-13

如果要匯出DD使用者下的所有定義,那麼在SQL*Plus中程式碼如下所示:

SET PAGESIZE 0
SET TRIMSPOOL ON
SET LINESIZE 10000
SET LONG 90000
SET FEEDBACK OFF
SET FEED OFF
SET ECHO OFF
SPOOL /tmp/schema_dd.sql
SELECT CASE
         WHEN U.OBJECT_TYPE IN
              ('PROCEDURE', 'FUNCTION','PACKAGE', 'TRIGGER') THEN
          DBMS_METADATA.GET_DDL(U.OBJECT_TYPE, U.OBJECT_NAME, 'DD') ||
          CHR(10) || '/'
         ELSE
          DBMS_METADATA.GET_DDL(U.OBJECT_TYPE, U.OBJECT_NAME, 'DD')||
          CHR(10) || ';'
       END AS SCOTT_DDL
  FROM USER_OBJECTS U
 WHERE U.OBJECT_TYPE IN
       ('PROCEDURE','FUNCTION','PACKAGE','TRIGGER')
       AND U.OBJECT_NAME not like 'BIN%';
SPOOL OFF;

則可以匯出DD使用者下所有的DDL語句到/tmp/schema_dd.sql檔案中。


找DDL中的關鍵字
fgrep 999 * | grep -v 999999
fgrep 9999 * | grep -v 999999
fgrep CN30006 * | grep -v CN300006
fgrep CN3000006 * | grep -v CN300006


另外一個更簡單的找關鍵字的方法
select * from dba_source t where OWNER='DD' and upper(text) like '%999%' and upper(text) not like '%999999%';
select * from dba_source t where OWNER='DD' and upper(text) like '%CN30006%' and upper(text) not like '%CN300006%';
select * from dba_source t where OWNER='DD' and upper(text) like '%CN3000006%' and upper(text) not like '%CN300006%';








來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/725820/viewspace-2214152/,如需轉載,請註明出處,否則將追究法律責任。

相關文章