반응형


다운로드 주소 : http://technet.microsoft.com/ko-kr/sysinternals/bb896649(en-us).aspx

PStool 패키지 안에 포함되어 있는 툴들

  • PsExec - execute processes remotely
  • PsFile - shows files opened remotely
  • PsGetSid - display the SID of a computer or a user
  • PsInfo - list information about a system
  • PsKill - kill processes by name or process ID
  • PsList - list detailed information about processes
  • PsLoggedOn - see who's logged on locally and via resource sharing (full source is included)
  • PsLogList - dump event log records
  • PsPasswd - changes account passwords
  • PsService - view and control services
  • PsShutdown - shuts down and optionally reboots a computer
  • PsSuspend - suspends processes
  • PsUptime - shows you how long a system has been running since its last reboot (PsUptime's functionality has been incorporated into PsInfo)
  • 반응형
    반응형

    오늘 마이크로소프트 사에서 프로세스를 엑세스 할수 있는 강력한 툴이 있다는 것을 알았다.

    관련 페이지 : http://technet.microsoft.com/ko-kr/sysinternals/bb896653(en-us).aspx

    Process Explorer v12.04
    어떤 프로그램 디렉토리 특정 파일들을 열고 있는지 궁금하지 않는가?


    이제 우리는 발견할 수 있다.  Process Explorer 는 DLL 프로세서 들이 열었거나 로드된 정보를 조회할 수 있다.

    Process Explorer는 두 개의 창으로 구성되어 화면 표시 된다.  위쪽 윈도우는 현재 동작중인 프로세스들의 그것들의 소유계정 정보의 이름 리스트들을 나타낸다.
    아래 창에는 그 프로세스가 사용하는 디렉토리, 이벤트, 파일, 세마포어, 스레드 등이 표시된다.

    또한 위쪽 창에서 마우스 오른 쪽 버튼을 누르면 프로세스를 죽일수 있는 Kill Processor 가 뜬다.
    '
    nProtect 등 각종 프로그램 (윈도우즈에서 작업 관리자에서 강제 종료가 안되는) 도 종료할 수 있다.



    반응형
    반응형

    EXCEPTION
        WHEN exception명1 [OR exception명2...] THEN
            문장1;
            문장2; ...
        [WHEN exception명3 [OR exception명4...] THEN
            문장1;
            문장2; ...]
        [WHEN OTHERS THEN
            문장1;
            문장2; ...]

     

    WHEN OTHERS 구문은 EXCEPTION 처리의 마지막 구문으로서 미리 선언되지 못한 모든 경우의 EXCEPTION처리를 가능하게 합니다.

    EXCEPTION Keyword에 의해 Error처리가 시작됩니다.

    EXCEPTION 처리구문이 필요하지 않으면 생략할 수 있습니다.

     

    =========================================================================================

    Predefined EXCEPTION

    DECLARE Section에서 선언할 필요가 없습니다.  

    Oracle Server 에러 중에서 자주 발생되는 20가지 에러에 대해 미리 정의되어 있는 EXCEPTION입니다.

    해당 EXCEPTION 처리 루틴에서 미리 정의된 EXCEPTION명을 참조하여 에러를 처리합니다.
    Predefined EXCEPTION의 종류에는 다음과 같은 것들이 있습니다.

    EXCEPTION명

    에러번호

    설   명

    NO_DATA_FOUND

    ORA-01403

    데이터를 반환하지 않은 SELECT문

    TOO_MANY_ROWS

    ORA-01422

    두 개 이상을 반환한 SELECT문

    INVALID_CURSOR

    ORA-01001

    잘못된 CURSOR 연산 발생

    ZERO_DIVIDE

    ORA-01476

    0으로 나누기

    DUP_VAL_ON_INDEX

    ORA-00001

    UNIQUE COLUMN에 중복된 값을
    입력할 때

    CURSOR_ALREADY_OPEN

    ORA-06511

    이미 열러 있는 커서를 여는 경우

    INVALID_NUMBER

    ORA-01722

    문자열을 숫자로 전환하지 못한 경우

    LOGIN_DENIED

    ORA-01017

    유효하지 않은 사용자로 LOGON 시도

    NOT_LOGGED_ON

    ORA-01012

    PL/SQL 프로그램이 오라클에 연결되지
    않은 상태서 호출

    PROGRAM_ERROR

    ORA-06501

    PL/SQL 내부에 오류

    STORAGE_ERROR

    ORA-06500

    PL/SQL에 메모리 부족

    TIMEOUT_ON_RESOURCE

    ORA-00051

    오라클이 자원을 기다리는 동안 시간
    초과 발생

    VALUE_ERROR

    ORA-06502

    산술, 절단 등에서 크기가 다른 오류 발생

    ======================================================================================

     

    CREATE OR REPLACE PROCEDURE show_emp
    (v_salary   IN   s_emp.salary%type )
    IS
    v_name    s_emp.name%TYPE;
    v_sal        s_emp.salary%TYPE;
    v_title      s_emp.title%TYPE;
    BEGIN
    SELECT name, salary, title
    INTO v_name, v_sal , v_title
    FROM s_emp
    WHERE salary = v_salary ;
    DBMS_OUTPUT.PUT_LINE(' 이 름 '||' 급 여 '||' 직 책 '  );
    DBMS_OUTPUT.PUT_LINE('--------------------------------' );
    DBMS_OUTPUT.PUT_LINE(v_name ||v_sal ||v_title);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
       DBMS_OUTPUT.PUT_LINE('ERROR!!!-해당급여를 받는 사원은
    없습니다.');
    WHEN TOO_MANY_ROWS THEN
       DBMS_OUTPUT.PUT_LINE('ERROR!!!-해당급여를 받는 사원이
    너무 많습니다.');

    END;
    /

     

    SQL>EXECUTE show_emp (2400)
        ERROR!!!-해당급여를 받는 사원이 너무 많습니다.
        PL/SQL 처리가 정상적으로 완료되었습니다.

    SQL>EXECUTE show_emp (500)
        ERROR!!!-해당급여를 받는 사원은 없습니다.
        PL/SQL 처리가 정상적으로 완료되었습니다.

    Non-Predefined EXCEPTION

    Oracle Server Error중 미리 정의되지 않은 Error는 사용자가 DECLARE Section에서 EXCEPTION명을 정의하고 Oracle Server에서 제공하는 Error번호를 사용하여 Error와
    연결한 후 EXCEPTION Section에서 Error처리 Routine을 기술합니다.

    DECLARE
       exception명 EXCEPTION;
       PRAGMA EXCEPTION_INIT(exception명, 에러번호);
    BEGIN
    . . .
    EXCEPTION
        WHEN exception명 THEN
    . . .
    END;

     


     

    S_PRODUCT 테이블에서 제품번호를 입력받아 제품을 삭제하는 프로그램을
    작성하면 다음과 같습니다.
    Oracle Server 에러번호 -2292인 무결성 제약조건 위반 에러처리를 합니다.

     

    CREATE OR REPLACE PROCEDURE del_product
    (  v_id  IN     s_product.id%TYPE )
    IS
      
     fk_error     EXCEPTION;
       PRAGMA    EXCEPTION_INIT(fk_error , -2292);

    BEGIN
       DELETE FROM  s_product
       WHERE                id = v_id;
       COMMIT;
    EXCEPTION
      
     WHEN fk_error THEN
         ROLLBACK;
         DBMS_OUTPUT.PUT_LINE('참조되는 CHILD RECORD가 있으므로 삭제할
    수 없습니다.');

    END;
    /

     

     

    SQL>EXECUTE del_product(50530)
    참조되는 CHILD RECORD가 있으므로 삭제할 수 없습니다.

    PL/SQL 처리가 정상적으로 완료되었습니다.    

    User Defined EXCEPTION

    사용자 정의 EXCEPTION은 Oracle Server Error는 아니고, 사용자가 정한 조건이 만족되지 않을 때, Error를 발생시키는 방법입니다.

    DECLARE Section에서 EXCEPTION명을 정의하고
    BEGIN Section에서 RAISE문을 써서 에러를 발생시킵니다. 그리고 EXCEPTION Section에서 에러 처리문을 기술합니다.

    DECLARE
        exception명 EXCEPTION;
    BEGIN
       RAISE exception명;
    . . .
    EXCEPTION
        WHEN exception명 THEN
    . . .
    END;

     



     

    S_EMP 테이블에 새로운 사원을 입력하는 프로그램을 작성하면
    다음과 같습니다.단, 사번은 일련번호로 부여할 수 있도록 값을 지정하고
    이름, 직책, 급여, 커미션은 사용자가 입력합니다.
    단, 급여를 600이하로 입력시에는 입력이 불가능하도록 처리합니다.

     

    CREATE OR REPLACE PROCEDURE in_emp
    (v_name    IN    s_emp.name%TYPE ,
     v_sal      IN    s_emp.salary%TYPE ,
     v_title     IN    s_emp.title%TYPE ,
     v_comm   IN    s_emp.commission_pct%TYPE )
    IS
    v_id       s_emp.id%TYPE ;
    lowsal_err   EXCEPTION ;
    BEGIN
      SELECT MAX(id)+1
      INTO v_id
      FROM s_emp ;
     IF  v_sal  >= 600 THEN
      INSERT INTO  s_emp
       (id,name,salary,title,commission_pct,start_date)
      VALUES(v_id,v_name, v_sal,v_title,v_comm,SYSDATE) ;
     ELSE
      RAISE  lowsal_err ;
     END IF ;
    EXCEPTION
    WHEN lowsal_err THEN
      DBMS_OUTPUT.PUT_LINE ('ERROR!!!-지정한 급여가 너무 적습니다.
    600이상으로 다시 입력하세요.') ;

    END;
    /

     

     

    SQL>EXECUTE in_emp('김흥국',500,'과장',12.5)
    ERROR!!!-지정한 급여가 너무 적습니다.600이상으로 다시 입력하세요.
    PL/SQL 처리가 정상적으로 완료되었습니다.  

    SQL>EXECUTE in_emp('김흥국',900,'과장',12.5)
    PL/SQL 처리가 정상적으로 완료되었습니다

     

    일반적인 Error처리를 위하여 Oracle에서 제공하는 함수인 SQLCODE, SQLERRM을
    활용할 수 있습니다.

    SQLCODE : Oracle에서 지정된 Error Code를 숫자로 Return

    SQLERRM :

    Oracle에서 지정된 Error Code에 해당하는 Error Message를
    Return

     

    SQLCODE, SQLERRM 함수를 활용하는 것 외에도 WHEN OTHERS절을 사용하여 Error를
    처리할 수 있습니다. WHEN OTHERS절은 예상치 못한 Error처리를 위해서 미리 선언되지
    않은 모든 종류의 Error를 처리합니다.

    이번에는 SQLCODE와 SQLERRM에 대해서 예를 통해 살펴봅니다.



    User Defined EXCEPTION의 예제9에서 작성한 Procedure를 이용하여 데이터를
    입력하되 단, 커미션을 30%로 지정하여 실행하시오.

     

    BEGIN in_emp('이한이',1200,'사원',30); END;

    *
    1행에 오류:
    ORA-02290: 체크 제약조건(SCOTT.S_EMP_COMMISSION_PCT_CK)이
    위배되었습니다
    ORA-06512: "SCOTT.IN_EMP", 줄 14에서
    ORA-06512: 줄 1에서  

     

     

    SQL>SELECT constraint_name, constraint_type, search_condition
        2  FROM user_constraints
        3  WHERE table_name = 'S_EMP' ;


     

     


     

    예제 9에서 실행시에 해당 COMMISSION_PCT를 입력하지 않는 경우에도
    프로그램이 정상적으로 수행되도록 User Defined EXCEPTION의 예제9에서
    작성한 프로그램을 보완하면 다음과 같습니다.

     

    CREATE OR REPLACE PROCEDURE in_emp
    (v_name    IN    s_emp.name%TYPE ,
     v_sal      IN    s_emp.salary%TYPE ,
     v_title     IN    s_emp.title%TYPE ,
     v_comm   IN    s_emp.commission_pct%TYPE )
    IS
    v_id            s_emp.id%TYPE ;
    lowsal_err   EXCEPTION ;
    v_code         NUMBER ;
    v_message    VARCHAR2(100) ;
     
    BEGIN
      SELECT MAX(id)+1
      INTO v_id
      FROM s_emp ;
     IF  v_sal  >= 600 THEN
      INSERT INTO  s_emp
       (id,name,salary,title,commission_pct,start_date)
      VALUES(v_id,v_name, v_sal,v_title,v_comm,SYSDATE) ;
     ELSE
      RAISE  lowsal_err ;
     END IF ;
    EXCEPTION
    WHEN lowsal_err THEN
      DBMS_OUTPUT.PUT_LINE ('ERROR!!!-지정한 급여가 너무 적습니다.
    600이상으로 다시 입력하세요.') ;
    WHEN OTHERS THEN
       v_code := SQLCODE ;
       v_message := SQLERRM ;
    DBMS_OUTPUT.PUT_LINE('에러코드   =>'||v_code) ;
    DBMS_OUTPUT.PUT_LINE('에러메세지=>'||v_message) ;

    END;
    /

     

     

    SQL>EXECUTE in_emp('이한이',1200,'사원',30)
    에러코드   =>-2290
    에러메세지=>ORA-02290: 체크 제약조건
    (SCOTT.S_EMP_COMMISSION_PCT_CK)이 위배되었습니다

    PL/SQL 처리가 정상적으로 완료되었습니다.

    반응형

    'Database > ORACLE' 카테고리의 다른 글

    System Account Lock (System 계정 락 걸림)  (0) 2010.07.15
    오라클 클론 디비로 복구 하기  (0) 2010.07.13
    RMAN 사용법  (0) 2010.07.06
    오라클 암호화 기능  (0) 2010.07.02
    오라클 pump 관련 자료  (0) 2010.06.30
    반응형

    ################################################################
    1. Backup 하기

    ################################################################



    1.
    백업 가능대상
     

     - database (all datafile 과 현재 control file)
     - tablespace
     - datafile (current 또는 image copy)
     - archived redo log
     - control file (current 또는 image copy)
       
    * 백업이 되는 않는 대상( init.ora, password file. listener.ora, tnsnames.ora, BFILES)

     

    2. 백업 분류 

     - consistent vs Inconsistent 백업

         RMAN을 통한 백업은 대상 DB open 혹은 close된 시점에서 백업이 가능하며, open 상태에서의 백업은 항상 Inconsistent 이며, consistent 백업은 항상 mount상태에서 백업을 받은 것을 말하며 이전에 DB crash되거나 비 정상 종료가 되지 않아야 한다.

         ( NOARCHIVE MODE에서는 INCONSISTENT 백업을 허용하지 않는다)  


    3.
    백업 방법
    3.1 전체 database 백업 

     run {

            allocate channel c1 device type disk;

            backup database

            format ‘/data/backup/rman/%d_%p_%t’;

      }

     
    3.2 tablespace 백업

     run {

           allocate channel c1 device type disk;

           allocate channel c2 device type disk;

           allocate channel c3 device type disk;

           backup filesperset=3                                  ## 한 백업set datafile 3개를 넘어서 백업받지 않는 조건

           tablespace example , users,system

           include current controlfile;                          ## 현재 control file도 같이 백업

     }


    3.3 datafile
    백업

     run {

           allocate channel c1 device type disk;

           backup  datafile 1, 2, 3, 4, 5, 6 ;

     }

     
    3.4 datafile copy

     run {

            allocate channel c1 device type disk;   

            backup datafilecopy ‘/home/oracle/oradata/testdb/users01.dbf’

            format ‘/data/backup/rman/users01.bak’;

     }

     
    3.5 current control file 백업

     run {

           allocate channel ch1 type disk;

           backup current controlfile

           tag = mondayPMbackup;

      }

     
    3.6 다른 object 백업시 control file 백업 추가 방법

     run {

           allocate channel ch1 type disk;

           backup tablespace users

           include current controlfile;                          ## users 라는 tablespace 백업시 currnet control file 포함

     }

     
    3.7 Archive redo log 백업

     

     run {

           allocate channel ch1 type disk;

           backup archivelog all                                 ## archive된 모든 redo log 백업

           delete input;                                               ## 백업받은 archive log 삭제

     }

     

     * archived redo log 백업시 time, SCN, log sequence number 조건을 사용해서 백업 받을수 있다.

        예) time 조건

     run {

            allocate channel ch1 type disk;

            backup archivelog

            from time ‘SYSDATE-2’ until time ‘SYSDATE-1’;         ## 2일전부터 1일전까지 발생한 archived redolog

     }                                                                                              

     

    4. incremental 백업

     

     run {

           allocate channel ch1 type disk;

           backup incremental level=0                        ## level 0 으로 database incremental backup

           database;

     }

     

     run {

           allocate channel ch1 type disk;

           backup incremental level=1                        ## level 1 system tablespace sale.f datafile 을 백업

           tablespace system                                     ##   하는데 level 0 또는 1이후로 변경된 사항만

           datafile ‘/home/oracle/oradata/testdb/example01.dbf’;   ##                     백업받는다.

     }

     

     run {

           allocate channel ch1 type disk;

           backup incremental level=2 cumulative       ## level 2 tbs_1 tablespace 백업하는데 level 0 또는 1

           tablespace  example;                                 ## 이후로 변경된 사항만 백업(cumulative 옵션사용)

     }

     

     

    5. image copies

     

    1. datafile

    2. archived redo log

    3. control file

     
    5.1 datafile controlfile image copy

    1)

     run {

           allocate channel ch1 type disk;

           copy

           datafile 1 to ‘/data/backup/rman/df_1.bak,

           datafile 2 to ‘/data/backup/rman/df_2.bak’,

           datafile 3 to ‘/data/backup/rman/df_3.bak’,

           datafile 4 to ‘/data/backup/rman/df_4.bak’,

           current controlfile to ‘/data/backup/rman/control.bak;

     }

     

      

    ################################################################
    Restore

    ################################################################

     

    1. Restore Datafile, Controlfile, Archived redo log file

     - restore 명령으로 백업set이나 image copy본에서 restore가능하다.

     (image copy본은 disk에서만 가능)

     

    2. restore database

     - database restore시에는 db는 항상 close상태이어야 한다. (db open된 상태라면 아래와 같이 shutdown , startup mount 상태로 한다.)

     

         shutdown immediate

         startup mount

     

    ex) 기존의 datafile 위치에 database restore 하는경우

     run {

           allocate channel ch1 type disk;

           allocate channel ch2 type disk;

           allocate channel ch2 type disk;

           restore database;

     }

     

    3. tablespace datafile restore
    3.1 기존위치에 tablespace restore

     run {

            sql ‘alter tablespace example offline ’;

            allocate channel ch1 type disk;

            restore tablespace  example;

     }

     
    3.2 새로운 위치에 tablespace restore

     run {

            allocate channel ch1 type disk;

            sql ‘alter tablespace  example offline’ ;

             ## 새로운 위치에 datafile restore

             set newname for datafile ‘/home/oracle/oradata/testdb/example01.dbf’
              
    to ‘/home/oracle/temp/example01.dbf’;

             restore tablespace example;

             ## 변경된 위치로 control file이 인식할 수 있게 함

             switch datafile all;

     }


    4. control file restore

     - nomount 단계에서 restore 해야함

     run {

           allocate channel ch1 type disk;

           restore controlfile;

           alter database mount;

     }

     

    5. Archived redo log restore

     - mount 단계에서 restore

     run {

           ## init.ora 에 명시되어있는 log_archive_dest 위치가 아니 다른 위치에 restore하고자 할때

           set archivelog destination to ‘/oracle/temp_restore’;

           allocate channel ch1 type disk;

           restore archivelog all;

     }

      

    ################################################################
    Recovery

    ################################################################

    1. Complete Recovery
    1.1 recover database

     shutdown immediate;

     startup mount;

     

     run {

           allocate channel ch1 type disk;

           restore database;

           recover database;

     }

     
    1.2 recover database (control file 백업본을 restore하고 복구하는 경우)

     startup nomount;

     

     run {

            allocate channel ch1 type ‘sbt_tape’;

            restore controlfile;

            alter database mount;

            restore database;

            recover database;

            alter database open resetlogs;

     }

     * resetlogs database open한 경우 reset database명령수행이 필요하며, 다시 database를 백업받는다.

     
    1.3. recover tablespace
    1.3.1 database close상태이고 tablespace위치에 접근가능할 때

     run {

            allocate channel ch1 type disk;

            restore tablespace tbs_3;

            recover tablespace tbs_3;

     }

     
    1.3.2 database close상태이고 tablespace위치에 접근가능하지 못할 때
    (datafile 위치를 바꿀 필요가 있을때)

     run {

            allocate channel ch1 type disk;

            set newname for datafile ‘/disk1/oracle/tbs_1.f’ to ‘/disk2/oracle/tbs_1.f’;

            restore tablespace tbs_1;

            switch datafile all;

            recover tablespace tbs_1;

     }

     
    1.3.3 database open된 상태이고 tablespace위치에 접근가능할 때

     run {

            sql ‘alter tablespace user_data offline temporary’;

            allocate channel ch1 type disk;

            set archivelog destination to ‘/oracle/temp/arc1_restore’;

            restore tablespace user_data;

            recover tablespace user_data;

            sql ‘alter tablespace user_data online’;

     }


    1.3.4 database
    open된 상태이고 tablespace위치에 접근불가능할 때

     run {

            sql ‘alter tablespace tbs_1 offline temporary’;

            allocate channel ch1 type disk;

            set newname for datafile ‘/disk1/oracle/tbs_1.f’ to ‘/disk2/oracle/tbs_2.f’;

            restore tablespace tbs_1;

            switch datafile all;

            recover tablespace tbs_1;

            sql ‘alter tablespace tbs_1 online’;

     }


    2. Incomplete Recovery
    2.1 time base Incomplete Recovery

       time base Incomplete Recovery를 하고자 할 때는 time format을 확인한 후 작업해야 한다.

      (필요시 time format설정 변경)

     

       ) NLS_LANG=american

       NLS_DATE_FORMAT=’Mon DD YYYY HH24:MI:SS’

     

       database open시는 반드시 shutdown후 작업

         shutdown immediate;

         startup mount;

     

     run {

           set until time ‘Nov 15 1998 09:00:00’;

           allocate channel ch1 type ‘sbt_tape’;

           restore database;

           recover databse;

           alter database open resetlogs;

     }

     

       resetlogs database open후 반드시 recovery catalog database reset database 명령으로 초기화 후 target database를 백업 받도록 한다.

     


    2.2
    특정 SCN까지 recovery

     database open시는 반드시 shutdown후 작업

       shutdown immediate;

       startup mount;

     

     run {

           set until scn 1000;

           allocate channel ch1 type ‘sbt_tape’;

           restore database;

           recover database;

           alter database open resetlogs;

     }

     

       resetlogs database open후 반드시 recovery catalog database reset database 명령으로 초기화 후 target database를 백업 받도록 한다.

     


    2.3
    특정 log sequence까지 recovery

      어느시점까지 recovery할것인지는 v$log_history view 조회를 통해서 결정

     

       database open시는 반드시 shutdown후 작업

        shutdown immediate;

        startup mount;

     

     ## thread 1에 대해 log sequence 6 까지 recovery하는 예

     run {

           set until logseq 6 on thread 1;

           allocate channel ch1 type ‘sbt_tape’;

           restore database;

           recover database;

           alter database open resetlogs;

     }

      resetlogs database open후 반드시 recovery catalog database reset database 명령으로 초기화 후 target database를 백업 받도록 한다.


    3.  recovery catalog
    없이 DBPITR(DataBase Point In Time Recovery)할때

     - recovery catalog 없이 DBPITR 수행을 하고자 할때는 아래와 같은 몇가지 필요한 사항들이 있다

     - control file은 별도로 백업을 받아 두도록 한다.

        database 백업시 control file도 자동으로 백업을 받아지기는 하지만 그때 발생한 database 백업에 대한 정보를 가지고 있지 못하기 때문에 별도로 아래와 같이 백업을 받도록 한다.

     

         backup database;

        backup current controlfile tag = ‘database backup’;

     

        controlfile 백업시 tag 옵션을 사용하여 향후에 특정시점에 백업받은 controlfile을 사용할 수 있도록 한다.

     - tablespace 변경 시나 datafile 추가시 백업을 수행하도록 한다.(control file도 포함)

     

     예)

         catalog없이 rman 시작

         rman target / nocatalog

     

         만일 database open된 상태라면 shutdown mount시킨다.

         startup force mount;

     

         특정 임시위치에 control file restore

     run {

            set until time ‘Jun 18 1998 16:32:36’;

            allocate channel ch1 type disk;

            restore controlfile to ‘/tmp/cf.tmp’ from tag = ‘database backup’;

     }

     

     백업받은 특정 controlfile restore할 수 없을 때는 rman을 통해 restore받은 controlfile아래와 같은 sql 명령으로 백업받은 후 init.ora 관련 파라미터를 조정한후 다음단계를 수행하도록 한다.


     - sql > alter database backup controlfile to ‘/tmp/original_cf’;

     - database shutdown

     - init.ora 에 명시된 CONTROL_FILES 파라미터를 적절히 조정

     - 백업받은 controlfile을 적당한 위치에 copy

     - startup mount

     run {

            set until time ‘Jun 18 1998 16:32:36’;

            allocate channel ch1 type disk;

            restore database;

            recover database noredo;                         ## database Noarchive Mode일때 noredo 옵션사용

            alter database open resetlogs;                  ## Archive Mode일때는 noredo 옵션없이 recover한다.

     }


    출처 : cafe.naver.com/prodba
    반응형

    'Database > ORACLE' 카테고리의 다른 글

    오라클 클론 디비로 복구 하기  (0) 2010.07.13
    PL/SQL Exception  (0) 2010.07.06
    오라클 암호화 기능  (0) 2010.07.02
    오라클 pump 관련 자료  (0) 2010.06.30
    오라클 기본 유저 정보  (0) 2010.06.30
    반응형


    - 이클립스 상에서 오라클 DATABASE를 바로 연결하여 사용하는 방법을 기술한다.

    설치에 사용된 이클립스...




    Help -> SoftWare Update를 클릭


    1. Add Site를 누름 

    2.http://quantum.sourceforge.net/update-site/ (Location) 부분에 입력

    3. OK를 클릭

    4. Quantum 을 검색 한뒤

    5. Install 버튼 클릭



    6. NEXT를 클릭


    7. 사용 조건에 승인하고 Finish 를 클릭 -> 설치 완료
      
        - 아래와 같이 설치가 완료되어 다시 시작한다는 메시지가 뜨면 YES를 누르고 이클립스를 다시 시작함.
      


    8. 이클립스 상에서 Quantum 플러그인 추가

    window -> open Perspective -> other



    9. Other open Perspective 화면에서 Quantum DB를 선택함.


    10. 정상적으로 설치되었음을 확인할 수 있다.(연결정보 설정은 당연히 현재는 안되어 있음)

    11. 연결 정보를 다음과 같이 추가함.
    Database Bookmarks 탭상에서 빈공간에서 마우스 우클릭 -> New Bookmark... 클릭


    12.  ADD driver을 눌러 추가하자 ! (우리는 오라클을 추가할 것이다.)



    13. Add External Jar.. 늘 눌러 ojbc14.jar를 추가함.


    14. 아래와 같이 정보를 설정하고 Finish를 누름



    15. 입력한 Oracle 드라이버를 선택후 Next> 를 클릭


    16. 다음과 같이 DB 연결 정보를 입력
         userid : 연결ID
         passwd : 연결ID의 암호
         HOSTNAME : DB서버 주소
         PORT : 오라클 리스너 포트(일반적으로 1521)
         DATABASE NAME : SID NAME


    17. 북마크에서 사용할 이름을 지정함


    18. 17번까지의 설정을 모두 마치면 자동으로 연결되고(정보가 틀리지 않았다면)
         Quantum SQL Queries View상에서 쿼리를 입력후 초록색 ▶ 버튼을 누르면 하단의 Quantum Table View 상에서 데이터가 조회됨.





    P.$ :
    1. MySql 연결시에는 mysql-connector-java-5.1.6-bin.jar 파일을 다운받음
    2. 드라이버 선택 -> com.mysql.jdbc.Driver
    3. 연결 포트는 3306임.
    반응형
    반응형

    10 G부터 생긴 DBMS_CRYPTO 패키지가 있습니다.
    DBMS_CRYPTO.HASH를 사용해서 단방향 암호화가 가능 합니다.
    아래 내용 참고 하세요.

    oracle dbms_crypto (오라클 암호화)
    1. oracle md5
    ex :
    select rawtohex(DBMS_CRYPTO.Hash(to_clob(to_char('mcpicdtl.blogspot.com')),2))
    from dual;

    함수 DBMS_CRYPTO.Hash 의 2번자 인자에 2가 들어가 있다.
    이 파라미터가 1 : md4, 2 : md5, 4 : sh1 암호화 방식을 지징한다

    위 함수를 실행 시키기 위해서는 sysdba 으로 로그인 해야 하거나 .
    sysdba로 부터 DBMS_CRYPTO 에 대한 EXECUTE 권한을 위임 받으면 된다.


    == DBMS_CRYPTO ==
    OWNER : SYS

    * grant package access to existing users and roles as needed
    * 이 패키지를 사용하기 위해서는 사용자에 EXCUTE ON DBMS_CRYPTO 를 GRANT한다.
    AS SYS
    GRANT EXECUTE ON DBMS_CRYPTO TO 사용자;


    DBMS_CRYPTO DataType
    ================================================================================================
    BLOB        : A source or destination binary LOB
    CLOB        : A source or destination character LOB (excluding NCLOB)
    PLS_INTEGER : Specifies a cryptographic algorithm type (used with BLOB, CLOB, and RAW datatypes)
    RAW         : A source or destination RAW buffer
    ================================================================================================

    Algorithms
    ================================================================================================

    DBMS_CRYPTO Cryptographic Hash Functions
    =========================================================================
    HASH_MD4 : Produces a 128-bit hash, or message digest of the input message
    HASH_MD5 : Also produces a 128-bit hash, but is more complex than MD4
    HASH_SH1 : Secure Hash Algorithm (SHA). Produces a 160-bit hash.
    =========================================================================

    DBMS_CRYPTO MAC (Message Authentication Code) Functions
    ================================================================================================
    HMAC_MD5 : Same as MD5 hash function, except it requires a secret key to verify the hash value.
    HMAC_SH1 : Same as SHA hash function, except it requires a secret key to verify the hash value.
    ================================================================================================

    DBMS_CRYPTO Encryption Algorithms                                                                                        
    ================================================================================================                                                                                                                  
    ENCRYPT_DES       :  Data Encryption Standard.
                         Block cipher.
                         Uses key length of 56 bits.                                                     
    ENCRYPT_3DES_2KEY :  Data Encryption Standard.
                         Block cipher.
                         Operates on a block 3 times with 2 keys.
                         Effective key length of 112 bits.
    ENCRYPT_3DES      :  Data Encryption Standard.
                         Block cipher.
                         Operates on a block 3 times.                                                   
    ENCRYPT_AES128    :  Advanced Encryption Standard.
                         Block cipher.
                         Uses 128-bit key size.                                                   
    ENCRYPT_AES192    :  Advanced Encryption Standard.
                         Block cipher.
                         Uses 192-bit key size.                                                   
    ENCRYPT_AES256    :  Advanced Encryption Standard.
                         Block cipher.
                         Uses 256-bit key size.                                                   
    ENCRYPT_RC4       :  Stream cipher.
                         Uses a secret, randomly generated key unique to each session.  
    ================================================================================================
                                             
    DBMS_CRYPTO Block Cipher Suites
    ================================================================================================
    DES_CBC_PKCS5  : ENCRYPT_DES  + CHAIN_CBC + PAD_PKCS5
    DES3_CBC_PKCS5 : ENCRYPT_3DES + CHAIN_CBC + PAD_PKCS5
    ================================================================================================

     

    DBMS_CRYPTO Block Cipher Chaining Modifiers

    ================================================================================================                                                                                                                                                                                                                           
    CHAIN_ECB : Electronic Codebook.
                Encrypts each plaintext block independently.                                                                                                                                                                 
    CHAIN_CBC : Cipher Block Chaining.
                Plaintext is XORed with the previous ciphertext block before it is encrypted.                                                                                                                              
    CHAIN_CFB : Cipher-Feedback. Enables encrypting units of data smaller than the block size.                                                                                                                                                    
    CHAIN_OFB : Output-Feedback.
                Enables running a block cipher as a synchronous stream cipher.
                Similar to CFB, except that n bits of the previous output block are moved into
                the right-most positions of the data queue waiting to be encrypted.
    ================================================================================================

    DBMS_CRYPTO Block Cipher Padding Modifiers
    ================================================================================================
    PAD_PKCS5  : Provides padding which complies with the PKCS #5: Password-Based Cryptography Standard
    PAD_NONE   : Provides option to specify no padding.
               : Caller must ensure that blocksize is correct, else the package returns an error.
    PAD_ZERO   : Provides padding consisting of zeroes.
    ================================================================================================

    *제한 사항*
    VARCHAR2 데이터타입은 바로 DBMS_CRYPTO 를 사용할 수 없다. VARCHAR2 타입의 데이터를 AL32UTF8
    데이터베이스 캐릭터셋으로 바꾸고 이를 다시 RAW 데이터타입으로 변경하여 사용해야 한다.

     

    Exceptions
    DBMS_CRYPTO Exceptions

    ================================================================================================
    CipherSuiteInvalid : 28827 : The specified cipher suite is not defined.
    CipherSuiteNull    : 28829 : No value has been specified for the cipher suite to be used.
    KeyNull            : 28239 : The encryption key has not been specified or contains a NULL value.
    KeyBadSize         : 28234 : DES keys: Specified key size is too short.
                                           DES keys must be at least 8 bytes (64 bits).
                                 AES keys: Specified key size is not supported.
                                           AES keys must be 128, 192, or 256 bits in length.
                              
    DoubleEncryption   : 28233 : Source data was previously encrypted.
    ================================================================================================

     

    언제 ENCRYPT&DECRYPT 프로시저와 ENCRYPT&DECRYPT 함수를 사용하는가?
    프로시저 : LOB 데이터타입 ENCRYPT&DECRYPT 이용시
    함수     : RAW 데이터타입 ENCRYPT&DECRYPT 이용시( VARCHAR2데이터타입은 RAW 데이터타입으로 변경이후 사용 )

     

    언제 HASH 또는 MAC(Message Authentication Code) 함수를 사용하는가?
    DBMS_CRYPTO 패키지는 두가지의 일방향 해시함수 HASH & MAC 함수가 있다. 이 함수들은 임의 길이 입력메시지를
    고정길의 해시값으로 반환한다. 일방향 해시 함수는 오직 한방향이다. 입력메시지를 해시값으로 만들기는 쉬우나
    해시값을 입력된 값으로 생성하기는 쉽지 않다. 해시값들은 보안상 적어도 128비트가 되어야 한다.

    이것으로 데이터가 변경되었는지를 확인하는데 사용할 수 있다. 예로, 데이터를 저장하기 전에 사용자가 저장할
    데이터에 대한 해시값을 생성하기 위해 DBMS.CRYPTO.HASH 함수를 실행하여 저장하고, 나중에 데이터를 다시 보
    기 위해 해시함수를 다시 실행하여 처음 실행한 해시값과 이후에 실행한 해시값이 같은지를 비교하여 데이터가
    변경되었는지 확인할 수 있다.

    DBMS.CRYPTO의 HASH함수는 RAW나 LOB 데이터의 해시값을 생성하는 일방향 해시함수다. DBMS.CRYPTO의 MAC 함수
    역시 같지만 비밀키가 추가된다. 즉, 키를 가지고 있는 사람만이 데이터에 대한 해시값을 맞출 수 있는 것 이
    외는 HASH함수와 동일하다.

    MAC은 유저들사이의 파일들을 인증하기 위해 사용된다. 또한 단일사용자의 파일변경유무를 확인하기 위해 사용
    될 수 있다. 바이러스의 의한 파일변경등을 확인하기 위해서..
    사용자가 MAC을 사용하지 않았다면 바이러스에 의해 테이블 엔트리를 교체입력하여 해시값을 바꿀 수 있지만
    MAC을 사용한다면 바이러스는 키값을 알지 못하므로 할 수 없다.

     

    변환 규칙
    VARCHAR2를 RAW로 변환하기 위해서는 다음단계를 수행하는 UTL_I18N.STRING_TO_RAW함수를 사용
     - 현 데이터베이스 캐릭터셋 VARCHAR2를 AL32UTF8 데이터베이스 캐릭터셋 VARCHAR2로 변환
     - AL32UTF8 데이터베이스 캐릭터셋 VARCHAR2를 RAW로 변환
     
     예) UTL_I18N.STRING_TO_RAW('문자열','AL32UTF8')
     
    RAW를 VARCHAR2로 변환하기 위해서는 다음단계를 수행하는 UTL_I18N.RAW_TO_CHAR 함수를 사용
     - RAW를 AL32UTF8 데이터베이스 캐릭터셋 VARCHAR2로 변환
     - AL32UTF8 데이터베이스 캐릭터셋 VARCHAR2를 현 데이터베이스 캐릭터셋 VARCHAR2로 변환


     예) UTL_I18N.RAW_TO_CHAR (data, 'AL32UTF8');


    * VARCHAR2 컬럼에 암호화된 RAW 데이터타입의 데이터를 저정하려면, VARCHAR2에 맞도록 RAWTOHEX 또는
      UTL_ENCODE.BASE64_ENCODE 를 사용한다. 이 함수들은 각각 2, 4/3로 데이터를 확장한다.

      

    [출처] DBMS_CRYPTO|작성자 새내기


    반응형

    'Database > ORACLE' 카테고리의 다른 글

    PL/SQL Exception  (0) 2010.07.06
    RMAN 사용법  (0) 2010.07.06
    오라클 pump 관련 자료  (0) 2010.06.30
    오라클 기본 유저 정보  (0) 2010.06.30
    오라클 일괄 컴파일  (0) 2010.06.30
    반응형
    반응형

    'Database > ORACLE' 카테고리의 다른 글

    RMAN 사용법  (0) 2010.07.06
    오라클 암호화 기능  (0) 2010.07.02
    오라클 기본 유저 정보  (0) 2010.06.30
    오라클 일괄 컴파일  (0) 2010.06.30
    프로시저에서 엑셀파일 출력하기  (0) 2010.06.29
    반응형

    Oracle Created (Default) Users

    디폴트 유저 리스트

    유저

    디폴트 암호

    용도 및 설명

    SYS

    change_on_install

    오라클의 가장 기본적인 메타 데이터가 저장되는 스키마가 된다. SYS소유의 테이블, 뷰 등은 오라클 시스템에 의해 실시간으로 수정되며, 인위적으로 수정되어서는 않된다.
    디폴트 암호는 오라클을 인스톨하자마자 수정해야 한다.

    SYSTEM

    manager

    SYSTEM 스키마의 테이블과 뷰는 오라클 데이터베이스의 관리정보를 보여주고, 주변 관리도구를 위해 내부적으로 사용된다.

    SYSTEM 유저는X$ 테이블 등에 접근할 수 없고, 데이터베이스를 startup/shutdown 시킬수는 없지만 DBA권한을 부여받았다. 따라서 일반 사용자의 모든 스키마를 접근 가능하다.  

    DBSNMP

    dbsnmp

    Oracle SNMP (Simple Network Management Protocol) 툴을 위한 유저로써, Oracle Intelligent Agent 등 에서 오라클 서버에 접근하기 위해 사용한다. 디폴트 암호를 수정하기 위해서는 아래와 같이 한다.

    1. Remove all Jobs and Events currently registered against this database.
    2. Stop the Intelligent Agent

    Oracle7 - Oracle8i
    % lsnrctl dbsnmp_stop

    Oracle9i
    % agentctl stop

    1. Edit the $ORACLE_HOME/network/admin/snmp_rw.ora file. Add the following parameter:

    SNMP.CONNECT.<connect_string>.NAME=<username>
    SNMP.CONNECT.<connect_string>.PASSWORD=<password>

    The variable <connect_string> is the exact listing of the database name as it appears in the snmp_ro.ora file.

    If <username> is the default (DBSNMP), there is no need to specify the user here. Only the password is required.

    On UNIX, set the following permission on the "SNMP_RW.ORA" file:

    % chmod 600 snmp_rw.ora

    1. Change the DBSNMP password on the database. You can use either Security Manager, Sqlplus, or Server Manager. If you use SQLPlus or Server Manager, you can issue the following command:

    SQL> alter user "dbsnmp" identified by "<newpassword>";

    1. Stop and restart the Intelligent Agent.

    OUTLN

    outln

    Oracle8i 이후 추가된 유저로, 옵티마이저의 실행계획을 고정시킬때 사용하는 OUTLINE 기능을 위해 사용된다. OUTLN 유저는 DBA 권한을 갖고 있다.

    MDSYS

    mdsys

    지리 정보 저장을 위한 Oracle Spatial 기능을 위해 추가된 유저. 관련된 테이블, 프로시져등을 접근하고 분석할때 사용된다.

    ORDSYS

    ordsys

    Oracle8i Time Series를 지원하기 위해 추가된 유저. TIMESTAMP 를 지원하는것이 주요 기능으로 Oracle 8i 때 추가되었다.

    ORDPLUGINS

    ordplugins

    Oracle interMedia 기능을 위해 추가된 유저. Oracle interMedia 는 멀티미디어 저장을 위해 만들어진 추가툴이다.

    CTXSYS

    ctxsys

    Oracle ConText Cartridge 기능을 위해 추가된 유저. 이 기능은 대량의 텍스트 정보에서 원하는 서치를 빠르게 해주는 기능이다.

    DSSYS

    dssys

    Dynamic Services Secured Web Service 를 위해 추가된 유저. Dynamic Services supports content access from databases (SQL/PLSQL) as well as Internet applications (HTTP/HTTPS). DS Engine can interpret XML and HTML content along with the result sets returned from database access. DS Engine is integrated with Oracle Portal via a Web Provider mechanism. This integration allows all the services registered with DS Engine to be accessible as portlets.

    PERFSTAT

    perfstat

    Oracle Statistics Package (STATSPACK) 를 지원하기 위한 유저. $ORACLE_HOME/rdbms/admin/spcusr.sql  스크립트로 생성시킨다.

    WKPROXY

    change_on_install

    Oracle's Ultrasearch option 을 위한 유저로Oracle9i 에서 추가되었다. $ORACLE_HOME/ultrasearch/admin/wk0csys.sql  스크립트로 생성시킨다.

    WKSYS

    change_on_install

    Oracle's Ultrasearch option 위한 또다른 유저.

    This support account is assigned the following privileges in Oracle9i:

    • CONNECT
    • RESOURCE
    • DBA
    • ALL PRIVILEGES
    • CTXAPP
    • CREATE PUBLIC SYNONYM
    • DROP PUBLIC SYNONYM
    • CREATE ANY VIEW
    • DROP ANY VIEW
    • CREATE ANY TABLE
    • DROP ANY TABLE
    • CREATE ANY INDEX
    • DROP ANY INDEX
    • CREATE ANY SEQUENCE
    • DROP ANY SEQUENCE
    • CREATE ANY TRIGGER
    • DROP ANY TRIGGER
    • JAVAUSERPRIV
    • JAVASYSPRIV
    • SELECT ON SYS.USER$
    • SELECT ON SYS.V_$PARAMETER
    • SELECT ON SYS.GV_$INSTANCE
    • SELECT ON SYS.V_$DATABASE
    • SELECT ON SYS.DBA_CONSTRAINTS
    • SELECT ON SYS.DBA_JOBS
    • SELECT ON SYS.DBA_DB_LINKS
    • SELECT ON SYS.DBA_ROLE_PRIVS
    • SELECT ON SYS.DBA_LOCK
    • SELECT ON SYS.DBMS_LOCK_ALLOCATED
    • SELECT ON SYS.PROCEDURE$
    • SELECT ON SYS.DBA_TABLES
    • SELECT ON SYS.DBA_VIEWS
    • SELECT ON SYS.DBA_TAB_COLUMNS
    • EXECUTE ON SYS.DBMS_LOCK
    • EXECUTE ON SYS.DBMS_PIPE
    • EXECUTE ON SYS.DBMS_REGISTRY

    The default tablespace for this user will be "DRSYS" while its temporary tablespace will be "TEMP".

    $ORACLE_HOME/ultrasearch/admin/wk0install.sql 로 생성한다

    WMSYS

    wmsys

    Oracle Workspace Manager 에서 필요한 메타데이터를 저장하기 위해 사용되는 유저. Oracle9i 에서 추가되었다.

    $ORACLE_HOME/rdbms/admin/owmctab.plb 로 생성한다.

    XDB

    change_on_install

    SQL XML 기능을 위해 사용하는 유저. $ORACLE_HOME/rdbms/admin/catqm.sql  로 생성한다.

    ANONYMOUS

    ...IDENTIFIED BY VALUES 'anonymous'

    HTTP 를 통해Oracle XML DB를 접근하기 위해 사용되는 유저. $ORACLE_HOME/rdbms/admin/catqm.sql 로 생성한다.

    ODM

    odm

    Oracle Data Mining 기능을 위해 생성된 유저. oracle9i 에서 추가되었다. $ORACLE_HOME/dm/admin/dmcrt.sql  로 생성한다.

    ODM_MTR

    mtrpw

    Oracle Data Mining 기능을 위해 생성된 유저. oracle9i 에서 추가되었다. $ORACLE_HOME/dm/admin/dmcrt.sql

    OLAPSYS

    mtrpw

    OLAP 메타데이터 저장을 위한 유저. oracle9i 에서 추가되었다. $ORACLE_HOME/dm/admin/dmcrt.sql

    TRACESVR

    trace

    Oracle Trace for OEM in Oracle7 에서 추가됨. Oracle Trace Server 가 설치되어야 한다. Oracle 8 이후 버전에서 없어졌다.

    REPADMIN

    Managed by DBA when user is created.

    Replication 유저. DBA가 수동으로 생성해 주어야 한다. $ORACLE_HOME/ldap/admin/oidrsrms.sql , $ORACLE_HOME/ldap/admin/oidrsms.sql.

     

     

    Sample Schemas

    유저

    디폴트 암호

    용도 및 설명

    SCOTT

    tiger

    가장 오래된 오라클 샘플 유저.

    ADAMS

     

     

    JONES

     

     

    CLARK

     

     

    BLAKE

     

     

     

    Oracle9i Sample Schemas

    유저

    디폴트 암호

    용도 및 설명

    HR

    hr

    Human Resources schema. The Human Resources division tracks information on the company's employees and facilities.

    OE

    oe

    Order Entry schema requires "Oracle Spatial" option. The Order Entry division tracks product inventories and sales of the company's products through various channels.

    PM

    pm

    Product Media schema requires "Oracle JVM" and "Oracle Intermedia" options. The Product Media division maintains descriptions and detailed information on each product sold by the company.

    SH

    sh

    Sales History schema requires "Oracle OLAP Services" set up. The Sales History division tracks business statistics to facilitate business decisions.

    QS

    qs

    Queued Shipping schema The Shipping division manages the shipping of products to customer. The sample company has decided to test the use of messaging to manage its proposed B2B applications.

    QS_ES

    qs_es

    (Eastern Shipping)

    QS_WS

    qs_ws

    (Western Shipping)

    QS_OS

    qs_os

    (Overseas Shipping)

    QS_CB

    qs_cb

    (Customer Billing)

    QS_CS

    qs_cs

    (Customer Service)

    QS_ADM

    qs_adm

    (Administration)

    QS_CBADM

    qs_cbadm

    (Customer Billing Administration)

    JSERV Accounts

    The three JSERV accounts (AURORA$JIS$UTILITY$, AURORA$ORB$UNAUTHENTICATED and OSE$HTTP$ADMIN) are used internally by Enterprise Java Beans and CORBA Tools and created with randomly-generated passwords 'INVALID_ENCRYPTED_PASSWORD'.

    These 3 scripts are launched by init_jis.sql script to install the Oracle Servlet Engine (OSE).

    Changing their passwords would prevent the ORB from working. This is supposed to change in a future version so that you can change their password.

    유저

    디폴트 암호

    용도 및 설명

    AURORA$ORB$UNAUTHENTICATED

    <Random>

    Description: Create the public user for the Aurora/ORB. This is the identity any non-validated ORB client will run as. This is the user for users who don't authenticate in the Aurora/ORB

    Created By: jisorb.sql

    AURORA$JIS$UTILITY$

    <Random>

    Description: Create the public user for the Aurora/ORB. This is the identity any non-validated ORB client will run as. This is the user for users who don't authenticate in the Aurora/ORB

    Created By: jisbgn.sql

    OSE$HTTP$ADMIN

    <Random>

    Description: Create the public user for the Aurora/ORB. This is the identity any non-validated ORB client will run as. This is the user for users who don't authenticate in the Aurora/ORB

    Created By: jishausr.sql

     오라클 Q&A 게시판 | 방명록 | Home..

    반응형
    반응형


    오라클을 이관 후에는 컴파일을 일괄적으로 해야할 때가 존재한다...

    1. 일괄 컴파일

     

    Set heading off      
    Set feedback off      
    Set pages 1000      
     
     spool obj.sql
     select 'set termout on' from dual;
     select 'set echo on' from dual;      
          
     select 'alter trigger '||owner||'.'||object_name||' compile;'
     from dba_objects
     where status <> 'VALID'
     and object_type='TRIGGER';
         
     select 'alter package '||owner||'.'||object_name||' compile;'      
     from dba_objects      
     where status <> 'VALID'       
     and object_type='PACKAGE';      

     select 'alter package '||owner||'.'||object_name||' compile body;'     
     from dba_objects      
     where status <> 'VALID'       
     and object_type='PACKAGE BODY';

     select 'alter procedure '||owner||'.'||object_name||' compile;'       
     from dba_objects      
     where status <> 'VALID'       
     and object_type='PROCEDURE';      

     select 'alter function '||owner||'.'||object_name||' compile;'
     from dba_objects      
     where status <> 'VALID'
     and object_type='FUNCTION';

     select 'alter view '||owner||'.'||object_name||' compile;'       
     from dba_objects      
     where status <> 'VALID'       
     and object_type='VIEW';       
     
     spool off

    [출처] [Oracle] 데이타베이스 한꺼번에 Compile하기|작성자 미친예언자




    2. 일괄 컴파일

     host rm -rf comp1.sql comp2.sql
    set pages 300
    select count(1) as INVALID_OBJECT_COUNT from dba_objects where status !='VALID';
    set pages 0
    set line 1000
    set echo off
    set feedback off
    set space 0
    col compile for a1000
    select systimestamp as start_time from dual;
    spool comp1.sql
    select 'prompt '||object_type||' '||object_name||' compiling'||'
    prompt '||'
    alter '||object_type||' '||owner||'.'||object_name||' compile;' as compile
    from dba_objects
    where status !='VALID'
    and object_type !='PACKAGE BODY';
    spool off
    host ls -al comp1.sql
    host echo "select systimestamp from dual;" >> comp1.sql
    start comp1.sql
    show error
    spool comp2.sql
    select 'prompt '||object_type||' '||object_name||' compiling'||'
    prompt '||'
    alter package '||owner||'.'||object_name||' compile body;' as compile
    from dba_objects
    where status !='VALID'
    and object_type ='PACKAGE BODY';
    spool off
    host ls -al comp2.sql
    host echo "select systimestamp from dual;" >> comp2.sql
    start comp2.sql
    show error
    set echo on
    set feedback on
    set pages 3000
    set space 1
    col owner for a20
    col object_name for a28
    col object_type for a20
    col status for a16
    select owner,object_name,object_type,status from dba_objects
    where status !='VALID';
    select count(1) INVALID_OBJECT_COUNT from dba_objects where status !='VALID';
    select systimestamp as end_time from dual;


    3. 일괄 컴파일

     1. SQL> @?/rdbms/admin/utlrp.sql

    2. utlrp를 parallel하게...
    execute utl_recomp.recomp_parallel(4);

    3. 만약 ERP라면...위의 두개로 해결이 안될때에는...
    cd $AD_TOP/sql/adcompsc를 사용합니다.
    adcompsc <== 이게 산타님 말씀하신것 처럼 alter문장을 생성하여 실행합니다.
    참고하세요^^

    반응형
    반응형

    여러가지 방법이 있겠지만

     

    엑셀에서 HTML 문서를 읽을 수 있다는 점에 착안해서 구현한 방법입니다.

     

    HTML로 테이블을 하나 만들어서 출력해버리면 엑셀에서 그대로 뿌려주는게 가능합니다.

     

    1. HTML 헤더부 생성

    2. 본문에 테이블 및 데이터 출력

    3. HTML 푸터부 생성

    4. spool할때 spool 파일의 확장자를 xls로 출력

     

    PS. 데이터 항목에 엑셀 함수를 뿌리면 엑셀에서 불러왔을때 해당 함수가 수행됩니다.

     

     

     

     

    UTL_FILE.PUT_LINE(v_FileHandle, '<html>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<head>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">');
    UTL_FILE.PUT_LINE(v_FileHandle, '<meta name="generator" content="SQL*Plus 10.2.0">');
    UTL_FILE.PUT_LINE(v_FileHandle, '<style type=''text/css''> body {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} p {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} table,tr,td {font:10pt Arial,Helvetica,sans-serif; color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} h1 {font:16pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;} h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} a {font:9pt Arial,Helvetica,sans-serif; color:#663300; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;}</style><title>SQL*Plus Report</title>');
    UTL_FILE.PUT_LINE(v_FileHandle, '</head>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<body>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<p>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<table border=''1'' width=''90%'' align=''center'' summary=''Script output''>');

     

     

    <위와 같이 HTML 헤더부를 생성>
     
     
     
     FOR data_rec IN GET_DATA_01 LOOP
    UTL_FILE.PUT_LINE(v_FileHandle, '<tr>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td>');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.TX_DATE);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.TOT);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.CARD);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.CAPI);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.DUP);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.NODATA);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.YESDATA);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
            UTL_FILE.PUT_LINE(v_FileHandle,data_rec.CORRATE);
    UTL_FILE.PUT_LINE(v_FileHandle, '</td>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<td align="right">');
    v_Rows := v_Rows + 1;
        END LOOP;
     
    <커서를 사용한 데이터 출력부>
     
     
     
    UTL_FILE.PUT_LINE(v_FileHandle, '</table>');
    UTL_FILE.PUT_LINE(v_FileHandle, '<p>');
    UTL_FILE.PUT_LINE(v_FileHandle, '</body>');
    UTL_FILE.PUT_LINE(v_FileHandle, '</html>');
     
    <HTML 문서의 푸터부를 구현>
    반응형

    + Recent posts