달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

'Work/ORACLE'에 해당되는 글 17

  1. 2012.10.11 Oracle Hot Backup
  2. 2011.06.14 Oracle Factorial
  3. 2011.04.27 is_number, is_date
  4. 2011.04.12 Oracle 복구
  5. 2011.03.14 How to Setup Sqlplus for Most Efficient Use on Windows XP (body scripted)
  6. 2011.01.20 Oracle Memory
  7. 2011.01.14 External Table
  8. 2011.01.06 Archive Mode vs No-Archive Mode
2012. 10. 11. 11:34

Oracle Hot Backup Work/ORACLE2012. 10. 11. 11:34

* Windows 기반 Oracle Hot Backup

1. Data file Backup

2. Control file Backup


* Backup Script 생성 Query
SELECT 
    CASE WHEN RN1= 1 THEN '/* some_label */ALTER TABLESPACE ' || TABLESPACE_NAME || ' BEGIN BACKUP;'  || CHR(13)||CHR(10) ELSE '' END
    || '/* some_label */host XCOPY ' || FILE_NAME || ' <Backup Path> /F /Y'
    || CASE WHEN RN2= 1 THEN CHR(13)||CHR(10) || '/* some_label */ALTER TABLESPACE ' || TABLESPACE_NAME || ' END BACKUP;' || CHR(13)||CHR(10) ELSE '' END
FROM (
    SELECT ROW_NUMBER() OVER (partition by TABLESPACE_NAME order by FILE_NAME)  RN1
        , ROW_NUMBER() OVER (partition by TABLESPACE_NAME order by FILE_NAME DESC)  RN2
        , TABLESPACE_NAME, FILE_NAME
    FROM DBA_DATA_FILES 
    )  A
ORDER BY TABLESPACE_NAME, FILE_NAME

* Sample
@ECHO OFF
 
REM Logging start backup
SET ds=%date%_%time%
SET ds=-- Scheduled Job Start : %ds:~0,22%
ECHO %ds%
 
REM Network drive check
REM NET USE M: /DELETE
REM NET USE M: \\203.xxx.xxx.xxx\ForxDB_Backups  <password>/USER:<id>
 
REM Connect SqlPlus...  Backup and Shutdown Oracle
FIND "/*%none% some_label" <%0 |sqlplus "/as sysdba"
GOTO end
: ----------- embedded SQL-------------------------
/* some_label */ALTER TABLESPACE FORXDB_BBS_DATA BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORXDB_BBS_DATA.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORXDB_BBS_DATA END BACKUP;

/* some_label */ALTER TABLESPACE FORXDB_BBS_INDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORXDB_BBS_INDX.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORXDB_BBS_INDX END BACKUP;

/* some_label */ALTER TABLESPACE FORXDB_INDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORXDB_INDX.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORXDB_INDX END BACKUP;

/* some_label */ALTER TABLESPACE FORXDB_STA_DATA BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORXDB_STA_DATA.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORXDB_STA_DATA END BACKUP;

/* some_label */ALTER TABLESPACE FORXDB_STA_INDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORXDB_STA_INDX.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORXDB_STA_INDX END BACKUP;

/* some_label */ALTER TABLESPACE FORXDB_USER BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORXDB_USER.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORXDB_USER END BACKUP;

/* some_label */ALTER TABLESPACE FORX_HOMEPAGE BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORX_HOMEPAGE01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORX_HOMEPAGE END BACKUP;

/* some_label */ALTER TABLESPACE FORX_HOMEPAGE_IDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\FORX_HOMEPAGE_IDX01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE FORX_HOMEPAGE_IDX END BACKUP;

/* some_label */ALTER TABLESPACE KPEG_HOMEPAGE BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\KPEG_HOMEPAGE.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE KPEG_HOMEPAGE END BACKUP;

/* some_label */ALTER TABLESPACE KPI_HOME_TS BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\KPI_HOME01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE KPI_HOME_TS END BACKUP;

/* some_label */ALTER TABLESPACE PCT_SUPPORT BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\PCT_SUPPORT.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE PCT_SUPPORT END BACKUP;

/* some_label */ALTER TABLESPACE SYSTEM BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\SYSTEM01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE SYSTEM END BACKUP;

/* some_label */ALTER TABLESPACE TS_DEV BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_03.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_04.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_05.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_06.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_07.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV\TS_DEV_08.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_DEV END BACKUP;

/* some_label */ALTER TABLESPACE TS_DEV2 BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_03.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_04.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_05.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_06.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_07.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV2\TS_DEV2_08.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_DEV2 END BACKUP;

/* some_label */ALTER TABLESPACE TS_DEV3 BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_03.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_04.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_05.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_06.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_07.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\DEV3\TS_DEV3_08.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_DEV3 END BACKUP;

/* some_label */ALTER TABLESPACE TS_IP_KOREA BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_IP_KOREA.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_IP_KOREA END BACKUP;

/* some_label */ALTER TABLESPACE TS_KIPI BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_KIPI01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_KIPI END BACKUP;

/* some_label */ALTER TABLESPACE TS_KIPIADM BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_KIPIADM02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_KIPIADM END BACKUP;

/* some_label */ALTER TABLESPACE TS_KIPIADM_IDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_KIPIADMIDX01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_KIPIADM_IDX END BACKUP;

/* some_label */ALTER TABLESPACE TS_KIPI_IDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_KIPI_IDX01 M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_KIPI_IDX END BACKUP;

/* some_label */ALTER TABLESPACE TS_KIPI_SUPPORT BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\KIPO_SUPPORT.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_KIPI_SUPPORT END BACKUP;

/* some_label */ALTER TABLESPACE TS_PERF_DATA BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_PERF_DATA01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\TS_PERF_DATA02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_PERF_DATA END BACKUP;

/* some_label */ALTER TABLESPACE TS_PIPC_HOME BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_03.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_04.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_05.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_06.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_07.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\PIPC_HOME\TS_PIPC_HOME_08.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_PIPC_HOME END BACKUP;

/* some_label */ALTER TABLESPACE TS_SEARCH BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_SEARCH01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\TS_SEARCH02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */host XCOPY E:\ORADATA\FORX\TS_SEARCH03.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_SEARCH END BACKUP;

/* some_label */ALTER TABLESPACE TS_WEB_IDX BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_WEB_IDX01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_WEB_IDX END BACKUP;

/* some_label */ALTER TABLESPACE TS_WEB_TXT BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\TS_WEB_TXT01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE TS_WEB_TXT END BACKUP;

/* some_label */ALTER TABLESPACE UNDOTBS1 BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\UNDOTBS01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE UNDOTBS1 END BACKUP;

/* some_label */ALTER TABLESPACE UNDOTBS2 BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\UNDOTBS02.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE UNDOTBS2 END BACKUP;

/* some_label */ALTER TABLESPACE USERS BEGIN BACKUP;
/* some_label */host XCOPY E:\ORADATA\FORX\USERS01.DBF M:\FORX1_ORADATA_BACKUP\ /F /Y
/* some_label */ALTER TABLESPACE USERS END BACKUP;

/* some_label */ALTER SYSTEM SWITCH LOGFILE;
/* some_label */ALTER DATABASE BACKUP CONTROLFILE 'M:\FORX1_ORADATA_BACKUP\CONTROLFILE\control01.ctl'

: ----------- end of embedded SQL-------------------------
:end
 
REM Logging end backup
SET ds=%date%_%time%
SET ds=-- Scheduled Job End : %ds:~0,22%
ECHO %ds%
ECHO.

* 참고 URL

:
Posted by Elick
2011. 6. 14. 11:21

Oracle Factorial Work/ORACLE2011. 6. 14. 11:21

SELECT EXP(SUM(LN(LEVEL))) 
FROM DUAL
CONNECT BY LEVEL <= N

위 처럼 하는 수 밖에 없는가..ㅠㅠ 
:
Posted by Elick
2011. 4. 27. 16:35

is_number, is_date Work/ORACLE2011. 4. 27. 16:35

오라클 사용시 가끔 사용할 일이 있는 type check 용 함수...
기본 제공을 안한다니 안타깝다..
기본제공 함수 누구 아는 사람 없나..ㅠㅠ

-----------
CREATE OR REPLACE FUNCTION is_number(v_str_number IN varchar2)
RETURN NUMBER
IS  /* 데이터가 number 형인지 검사하는 함수임. 1 이 나오면 NUMBER 형임 */
     V_NUM NUMBER;
BEGIN
  V_NUM := TO_NUMBER(v_str_number);
  RETURN 1;
EXCEPTION
  WHEN OTHERS THEN RETURN 0;
END;

CREATE OR REPLACE FUNCTION is_date(v_str_date IN varchar2, V_FORMAT IN VARCHAR2 DEFAULT 'YYYYMMDD')
RETURN NUMBER
IS   /* 데이터가 DATE 형인지 검사하는 함수임. 1 이 나오면 DATE 형임 */
     V_DATE DATE;
BEGIN
  V_DATE := TO_DATE(v_str_date, V_FORMAT);
  RETURN 1;   
EXCEPTION
  WHEN OTHERS THEN RETURN 0;
END; 
----------- 

:
Posted by Elick
2011. 4. 12. 13:37

Oracle 복구 Work/ORACLE2011. 4. 12. 13:37

최근에 겪은 이슈이다.

------------ xxx.trc-----------------
*** SESSION ID:(20.8) 2011-04-11 23:19:12.000
*** 2011-04-11 23:19:12.000
ksedmp: internal or fatal error
ORA-01114: 7 파일에 블록을 기록하는데 IO 오류입니다 (블록 번호 2620040)
ORA-27069: skgfdisp: I/O을 시도시 파일의 범위를 넘었습니다
OSD-04026: 부적합한 매개변수가 전달되었습니다. (OS 2620040)
ORA-01114: 7 파일에 블록을 기록하는데 IO 오류입니다 (블록 번호 2620040)
ORA-27069: skgfdisp: I/O을 시도시 파일의 범위를 넘었습니다
OSD-04026: 부적합한 매개변수가 전달되었습니다. (OS 2620040)
ORA-01114: 7 파일에 블록을 기록하는데 IO 오류입니다 (블록 번호 2620040)
ORA-27069: skgfdisp: I/O을 시도시 파일의 범위를 넘었습니다
OSD-04026: 부적합한 매개변수가 전달되었습니다. (OS 2620040)
ORA-01114: 7 파일에 블록을 기록하는데 IO 오류입니다 (블록 번호 2620040)
ORA-27069: skgfdisp: I/O을 시도시 파일의 범위를 넘었습니다
OSD-04026: 부적합한 매개변수가 전달되었습니다. (OS 2620040)
No current SQL statement being executed.
------------ xxx.trc-----------------

위의 에러가 발생했고...

대처를 적절히 하지 못해서 hot backup 된 것을 바로 replace 하기로 결정.
redo log 없고, controlfile, dbf 만 있는 상황....
복구시도를 했으나 번번이 실패...


과거에는 alter database open resetlogs 로 바로 복구되었는데 어찌된 일인지 아래처럼 안된다.

-----------  sqlplus --------------------
SQL> alter database open resetlogs;
alter database open resetlogs
*
1행에 오류:
ORA-01195: 1 파일의 온라인 백업은 일관성을 갖기위해 더 많은 복구가 필요로 합니다
ORA-01110: 1 데이터 파일:
SQL> 
-----------  sqlplus --------------------


하지만 pfile에 _ALLOW_RESETLOGS_CORRUPTION=TRUE option 적용 후 resetlogs 로 open.이 가능했다.

아.. 다행이다.. 

참고 url
http://practicalappsdba.wordpress.com/2008/04/01/how-to-recover-and-open-the-database-if-the-archive-log-required-for-recovery-is-missing/ 


주요 내용은 아래와 같다.

1) Set _ALLOW_RESETLOGS_CORRUPTION=TRUE in init.ora file.
2) Startup Mount
3) Recover database
4) Alter database open resetlogs.
5) reset undo_management to “manual” in init.ora file.
6) startup database
7) Create new undo tablespace
changed undo_management to “AUTO” and undo_tablespace to “NewTablespace”
9) Bounce database. 

:
Posted by Elick


How to Setup Sqlplus for Most Efficient Use on Windows

Sqlplus command line or console version is actually more powerful and efficient than its Windows or GUI version.note1 The feature that brings the greatest convenience is probably being able to press UP key to recall previous commands. With Oracle11g, the Windows version is no longer available, making the console version more than just appealing, but essential. This article summarizes some tips you may find useful in using the console version. I assume your desktop OS is XP unless otherwise noted.

1. Create a shortcut in Start menu

In Windows Explorer, at C:\Documents and Settings\user\Start Menu (where user is you or "All Users"), create a shortcut named for instance "Sqlplus" pointing to %oracle_home%\bin\sqlplus.exe, and prepend cmd.exe /k. (The path is different in Windows 7; see bottom of this page.) So the shortcut target looks like this:

cmd /k d:\oracle\product\10.2.0\Db_2\bin\sqlplus.exe

Because of cmd /k, if you exit sqlplus, sometimes accidentally by ^C, the console window remains open instead of closing itself. So you can still see the result on screen.

If for any reason you need to set oracle_home and oracle_sid just for running this sqlplus, i.e. not wanting to set it in Control Panel, the command will be:cmd /k set oracle_home=d:\oracle\product\10.2.0\db_2& set oracle_sid=orcl& d:\oracle\product\10.2.0\db_2\bin\sqlplus (adjust paths as needed). If you think too many environment variables should be set, put them in a batch file and call the file on this command instead. For instance, c:\10g.bat & cmd /k d:\...

I normally set "Start in" folder to somewhere other than the default %oracle_home%\bin, such as d:\temp, so a spooled file goes there by default.

Once this shortcut is there, you can quickly launch Sqlplus by going to Start -> Sqlplus. If you want to launch it even faster, set a shortcut key for it.

2. Adjust shortcut properties

Screen colors are probably the most important, ergonomically speaking. In Properties window for this shortcut, go to Colors tab, I strongly suggest you choose black for Screen Text and very light color or white for Screen Background. Trust me on this advice! Do an experiment with two console windows, one with white text in black background and the other with black text in white or light color background (see below). Make sure text font is exactly the same in size and face. Stand some distance away. You'll find that the text in the second window looks much clearer and you can read faster. I think the reason is that white text lines have more visible tiny black gaps than black text lines have white gaps.

Eye strain test

c:\ C:\WINDOWS\System32\cmd.exec:\ C:\WINDOWS\System32\cmd.exe
D:\>od -x D:\oracle\product\10.2.0\db_1\bin\sqlplus.exe|head -5
0000000 5a4d 0090 0003 0000 0004 0000 ffff 0000
0000020 00b8 0000 0000 0000 0040 0000 0000 0000
0000040 0000 0000 0000 0000 0000 0000 0000 0000
0000060 0000 0000 0000 0000 0000 0000 00f8 0000
0000100 1f0e 0eba b400 cd09 b821 4c01 21cd 6854
D:\>od -x D:\oracle\product\10.2.0\db_1\bin\sqlplus.exe|head -5
0000000 5a4d 0090 0003 0000 0004 0000 ffff 0000
0000020 00b8 0000 0000 0000 0040 0000 0000 0000
0000040 0000 0000 0000 0000 0000 0000 0000 0000
0000060 0000 0000 0000 0000 0000 0000 00f8 0000
0000100 1f0e 0eba b400 cd09 b821 4c01 21cd 6854

Don't be discouraged by only 16 color choices. You can adjust Red, Green and Blue to fairly high numbers to get your favorite light color, such as 200-255-200 for light green, 255-255-200 for beige, etc.

Now go to Options tab. Check QuickEdit mode and Insert mode checkboxes. It makes copy and paste of text easier. (If you see somebody send an image of Sqlplus text, you know he/she is very computer un-savvy!)

Under Font, choose a small font but not too small to your vision. I like Lucida Console, and not Bold version of it.

Under Layout, set Width for both Screen buffer and Window sizes to the same number, I would say at least 100, up to the full width of your screen, but make sure the vertical scroll bar is still visible near the right edge and no horizontal scroll bar is shown at the bottom. On my 19-inch monitor using 10-point Lucida Console font, I can get 188 in screen width. Set Height for Screen Buffer to 2000, or at least 1000. The reason you want the Sqlplus screen as wide as you feel comfortable is so that you'll have less cluster in the query output.

3. Sqlplus setting

Default pagesize 14 is absolutely inadequate. I prefer 100 (except in case of very wide tables such as some Oracle Applications AOL tables, where select * repeats headers too often even with pagesize 100). Since we widened our sqlplus console window in the last step to, say, 188, we should make full use of it. But due to a problem with console window,note2 you should set linesize to 1 less than window size, e.g., 187. The only time you want a smaller linesize is when you DESCribe a table or view, so that column names and types are not too far apart in DESC output. (Interestingly, this DESCribe feature is not for DESCribing a PL/SQL package or procedure.)

But typing these set commands every time you start Sqlplus would be tedious, even with abbreviations such as set pages 100 lin 187. So add them to%oracle_home%\sqlplus\admin\glogin.sql, or current directory or %sqlpath%\login.sql. If one or both of them are already in there, change or delete them. Other useful settings are:note3

set long some_big_number serveroutput on arraysize 100 trimspool on tab off ...
column plan_plus_exp format a100
...

With the above window width and Sqlplus linesize setting, query column values for the same row need to be vertically aligned with the column headers (and dash lines), as in the case of select * from a_wide_table... Because Sqlplus uses tabs for fast display, some column headings or even values may not align very well with dash lines under the headings. Set tab off to correct the problem. If you really prefer to see one data row shown on one row, the preferred tool is Toad or any one under Toad Alternatives. But Sqlplus is not completely hopeless; you can set both window width and Sqlplus linesize to a very big number like 1000 to achieve the same, except that you may still need to manually set the width for varchar2(a big number) columns to a smaller size (e.g., col mycol for a80).

4. Environment variables

The following are commonly used environment variables that affect the behavior of Sqlplus, which can also be set in Windows registry. But if they're set in both places, environment variables take precedence. If you need to find the current value of a variable regardless where it's set, you can type@[%the_variable_name%] at SQL> prompt to see it outputs the literal string you typed (which means it's not set) or its value (when it's set); try @[%oracle_home%]and @[%nosuchvar%] to see what I mean. For a fairly complete list of the variables, see Radoslav Rusinov's article (see pp.12-7; translate with Google Translate).

LOCAL: Windows equivalent of UNIX TWO_TASK environment variable. With this set, sqlplus user/pass is translated to sqlplus user/pass@value_of_%LOCAL%.

NLS_DATE_FORMAT: I like to set it to yyyymmdd hh24:mi:ss so DATE type columns are displayed in my favorite format. The console command is: set nls_date_format=yyyymmdd hh24:mi:ss. (Yes, there is ONE space between dd and hh24 and it's NOT interpreted by set as two arguments!) Setting this environment variable is preferred over adding alter session set nls_date_format='yyyymmdd hh24:mi:ss' to [g]login.sql because you won't get the annoying "Session altered" feedback upon login, and as a bonus, if you use RMAN from this console window, timestamp in RMAN shows in this format too. So you may consider setting it in Control Panel as a system-wide variable. See also NLS_LANG below.

NLS_LANG: The primary purpose of this variable is as the name suggests. If your PC uses a code page other than 437 (check by chcp console command), you may wish to set this variable to english or american, unless you want feedback for the Sqlplus commands to be shown in your own language. Sometimes this variable is also changed in order to display foreign language text stored in the database, before running imp or exp (but not expdp or impdp) to avoid character set conversion; if the database you export from and the one you import into have different character sets, Oracle recommends you set NLS_LANG for your exp and imp environment to the same as the source, not target, database. Not widely known about this variable or registry key is the fact that if for some reason the registry is missing this key, setting NLS_DATE_FORMAT environment parameter alone won't let you see the desired DATE format when you select sysdate from dual; but since NLS_LANG is automatically set in registry during Oracle software installation, you're probably not aware of this issue. Equally obscure is the fact that if your Sqlplus starts in an NLS_LANG setting that differs in character set from that of the database you run queries in, sometimes Sqlplus widens the column in the output for string type columns, either for a query or for the Sqlplus print command to print the bind variable value. To see the difference, run select username from user_users in databases that use different charactersets after you set NLS_LANG to these two values,.al32utf8 and .we8iso8859p1 (note the leading dot). But using the setting .we8mswin1252 seems to avoid this problem.

SQLPATH: If somescript is in this directory, you can type @somescript at SQL> prompt to run it without specifying full path.

5. Tips

Many people are used to typing edit (or ed for short) at SQL> prompt to launch an editor. The problem is that it litters the file afiedt.buf wherever you launch Sqlplus. You can limit this litter to one single place with set editfile some_fixed_path\somefile.note4 Unless your SQL or PL/SQL commands are multi-line, you may enjoy better pressing UP arrow key to retrieve previous commands. This is one of the best features of the console version Sqlplus. The command line buffer size is only 50 by default and can be changed under Options tab in Properties window. Also, don't just use LEFT and RIGHT keys; press Home key (with NumLock off) to go to line beginning, Control-LEFT/RIGHT to move one word instead of one character at a time, and Esc to clean current line immediately. F7 is a little known trick in console; it shows all saved commands in your history buffer up to the history size (see below). Once you press F7, you can move UP/DOWN to the one you want, LEFT or RIGHT to select it on your command prompt (SQL>), or Enter to directly select and execute it, or Esc to cancel.

The beautiful window from F7

c:\ yong@testdb
SQL>
SQL>
SQL>
40: select sysdate from dual;
41: select * from v$lock where type!='MR';
42: desc v$session
43: select * from v$session where sid=123;
45: alter system kill session '123,2345';
46: select * from v$lock where type!='MR';



Since we enabled Quick Edit, you can double click on a word or select text to highlight it, right click or press Enter to copy (no message telling you it's copied), and right click again to paste (or in most applications such as Notepad, ^V to paste). Do not press ^C or ^V in this console window. ^V does nothing and ^C either exits Sqlplus or, if the query is still running inside the database, stops the query. It may take you a while to get used to the console window's copy and paste, and it's very confusing to have wrong text copied when you accidentally highlight some text (you can tell by the changed window title that begins with "Select"). This accidental highlight also "freezes" the screen; if you know your query should return rows now but the screen "hangs", make sure there's no text highlighted. (If there is, press any key such as Space to un-highlight.)

Another good feature is that you can set console window title with command such as title yong@testdb. At SQL> prompt, prepend with $ or host (or hos for short): host title yong@testdb. With a title for the console window, you can quickly spot it when it's minimized on the taskbar. If you don't set the title, our Sqlplus window opened by this Start-button shortcut will be "sqlplus - full_path_to_sqlplus". If you have to frequently set title because you often change connections (dropping a table in Prod while you thought you were in Dev is not pretty!), or because you often press ^C ending up at console command prompt, you can save a little effort by creating a short named sqlplus.exe, such as s.exe by copying sqlplus.exe to s.exe (in Windows Vista, a symbolic link will do). You may as well rename the Start-button shortcut to single letter "s". Then you can type s yong@testdb. The Sqlplus window will automatically bear the title "s - s yong@testdb". Doing that saves some typing and hopefully the title is short enough to show in the minimized tab on taskbar. Some people prefer to customize SQL> prompt to show DB name and/or username. You can follow this instruction (section "My Personal SQL Prompt"). Beginning with 10gsqlprompt adjusts _connect_identifier and _user dynamically. Obviously the console Window title or the label on the minimized tab won't automagically show the same string.

It's unfortunate that Oracle 11g no longer provides Windows Sqlplus (sqlplusw.exe). Although I don't recommend it for general use, it has some interesting features compared with the console version Sqlplus. Both Windows and console Sqlplus allow you to vertically highlight or copy text; vertically highlighting indented text makes reading an execution plan easier. And both Sqlplus output lines on terminal strictly based on time or input order, unlike in a Linux/UNIX terminal, where pasting multi-lines of SQL to it shows the SQLs mixed with query result in the middle instead of at the end.note5 On the downside, the command console doesn't support here document, so you can't pipe SQL or Sqlplus commands to a SQL session, as you would be able to do on Linux/UNIX.note6

Both Windows and console Sqlplus allow for string search (in console Sqlplus, go to Edit | Find). But the console Sqlplus can find strings from the entire buffer, as much as you can scroll back to, while the Windows Sqlplus only searches the visible screen.

Having said all these, the Windows version Sqlplus does have some unique features missing in the console version:

  • Windows Sqlplus never exits out of Sqlplus when you press Control-C (UNIX/Linux sqlplus doesn't either), while the console Sqlplus may. This is a very annoying problem and may be the only good reason sometimes I still use the Windows Sqlplus. Hopefully Bug 8890996, an enhancement request filed by me in 2009, will eventually get Oracle's attention.
  • The Windows Sqlplus has much more powerful special character display than the console version. Try select chr(49833) copyright from dual; in both to see what I mean. The weak capability of the console version could be dangerous in some cases; if the text column has two Carriage Return's, the Windows Sqlplus shows a rectangular dot, which serves as a warning something is here, but the console version silently "erases" the first part of the text. Try select 'x'||chr(13)||'y'||chr(13)||'z' from dual;. The behavior doesn't change with different NLS_LANG settings.note7

6. Useful link

William Robertson's Setting up SQL*Plus on Windows is very user-friendly.

_________________

[note1] Some people call the command console a DOS window. But the correct way to say is that sqlplus.exe is a Win32 Console application, and sqlplusw.exe a Win32 GUI app. (Thanks to Dennis Yurichev's correction)

[note2] See details here. The problem does not exist on a UNIX/Linux terminal.

[note3] Set long big_number so you can see the definition of a complicated trigger or view, or text in any long or clob column. Serveroutput on is for dbms_output.put_line (but do NOT set it to on if you need to call dbms_xplan.display_cursor in 10g to show the plan for the last executed SQL), or if you simply don't like the little overhead of that one extra consistent get. A bigger than default 15 arraysize (or array for short) is to save on consistent gets; the default 15 is rarely adequate (Perhaps it increases a little sqlplus.exe process memory and server side PGA). Trimspool is to remove trailing space characters in the spool file padded to linesize so the file is smaller and lines don't "mysteriously" wrap.
Before 10g, column plan_plus_exp needs to be larger so your explain plan output doesn't wrap lines too early. It's interesting that plan_plus_exp can only be set to linesize-19 at maximum unless you reduce object_node_plus_exp; beyond that, explain plan output lines wrap. So if linesize is say 145, you need col plan_plus_exp for a126, not a127. Beginning with 10g client, you don't need to worry about this column setting.

[note4] If you set editfile nul:, you get "Incorrect function" message when you edit and the default editor is Notepad, as if you typed notepad nul: at command prompt. So this is not an option. (On Linux/UNIX, if you set editfile /dev/null, you see an empty vi editor and you get "/dev/null" is not a filemessage when you edit, as if you typed vi /dev/null at shell level.)

[note5] Private email with Don Libes, the author of the Expect programming language, confirms that there's no workaround for this feature of UNIX terminals, unless the program (sqlplus here) has custom code to avoid this "premature" echoing. But some shells behave better than others. For instance, in bash you would paste a lot of lines at once on a fairly fast connection to the terminal to see jumbled lines.

[note6] Somebody wrote a very clever script to mimic a here document in the command console (originally posted here):

@echo off
FIND "/*%none% some_label" <%0 |sqlplus username/password
GOTO end
: ----------- embedded SQL-------------------------
/* some_label */ select * from dba_free_space where rownum = 1;
/* some_label */ rem select tablespace_name from dba_tablespaces;
: ----------- end of embedded SQL-------------------------
:end

[note7] This is actually a problem with the Windows console, not Sqlplus itself. UNIX/Linux terminal suffers from the same problem. See my posting to Oracle-L.

[2011-08 Update]
In Windows 7, the path is
C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
You need to manually type AppData in the path since it's hidden.


:
Posted by Elick
2011. 1. 20. 17:37

Oracle Memory Work/ORACLE2011. 1. 20. 17:37

Oracle Server = Instance + Database
. Instance = Memory(SGA) + Backgroud Processes
. 오라클 데이터 베이스를 접속하는 문이다.
. 항상 하나의 데이터 베이스만을 open한다. (database는 여러개의 인스턴스가 가능 = RAC)
. instance에 의해 database는 mount(메모리를 할당 받은 상태)된다.
. SGA
 = Shared Pool + DB buffer Cache + Redo Log Buffer
. Backgroud Processes 
= PMON + SMON + SNPn + LCKn + REDO + Dnnn + Pnnn + CKPT + ARCH + LGWR + DBWR
 
. Database
. data files : meta data(data dictionary), user data
. control files : 오라클의 구조 정보 (동기화 정보, 물리적 그조)를 control하는 파일
. redo log files : 데이터가 변경된 레코드 저장

흐름
User Process -> Server Process -> PGA -> SGA -> Database -> User Process
. User Process : client에서 실행되며, sqlplus, developer/2000등의 application을 실행했을 때 생성
. Server Process
. user process의 요구를 받아 결과 값을 client에게 return한다.
. 각각의 user process마다 server process가 하나씩 생긴다.(1:1관계)
. 하나의 server process는 하나의 PGA를 생성한다.

User Process
. 사용자가 오라클 Application Program을 실행 시켰을 때 사용되는 프로세스이다. (sql*plus, Forms, Pro*C 등이 해당)
. 사용자가 오라클 서버에 접속할 때마다 사용자 프로세스가 생성된다.
. 사용자가 실행시킨 SQL문을 서버 프로세스에 전달하고, 그 결과를 서버 프로세스로부터 받아 수행한다.

Server Process
. Server Prorcess  정의
. Server에서 실행된다.
. 오라클은 서버프로세스를 생성하여 접속된 사용자 프로세스의 요구사항(SQL문)을 처리한다.
. 전용 서버 구성에서는 단일 사용자 프로세스에 대한 요구사항을 처리하며, 공유 서버 구성일 때는 여러 사용자 프로세스가 적은 수의 서버 프로세스를 공유하여 서버 프로세스 수를 최소화하는 동시에 사용 가능한 시스템 자우너 활용도를 최대화 한다.
 
. Server Process의 역할
전달받은  SQL문을 Parse, 실행(Execute), 패치(Fetch) 작업을 통행 실행시킨다.
. Parse
SQL문 문법 검사
사용자 인증 및 권한 검사
객체의 사용 가능 여부 검사
. Execute
parse과정에서 만들어진 parse tree로 원하는 데이터를 찾음
데이터를 찾은 후 실제 데이터 read 수행
필요할 경우 데이터 수정
. Fetch
데이터를 사용자 프로세스에게 전달
 
PGA
. PGA 정의
. 데이터베이스에 접속하는 유저에게 할당되는 각각의 서버 프로세스가 독자적으로 사용하는 오라클 메모리 영역.
. PGA는 프로세스가 생성될 때 할당되면 프로세스가 종료될 때 해제.
. 각각의 server process마다 하나의 PGA를 생성.
 
. PGA의 구조
정렬공간 (Sort Area)
 + 세션정보 (Session Information)
 + 커서 상태 정보 (Cursor State)
 + 변수 저장 공간 (Stack Space) 

. 정렬공간 : order by 또는 group by등의 정렬을 수행하기 위한 공간
. 세션정보 : 서버 프로세스에 의해 추출된 결과 값을 전달하기 위해 필요한 유저 프로세스의 세션정보 저장
. 커서상태정보 : 해당 SQL의 파싱 정보가 저장되어 있는 주소 저장
. 변수저장공간 : SQL문장에 바인드변수를 사용할 경우 해당 바인드 변수를 저장하는 공간
. UGA = 정렬공간 + 세션정보 + 커서상태정보

. PGA share and dedicated
전용 Server : PGA(Stack Area + Session Information) + SGA()
공유 Server : PGA(Stack Area) + SGA (Session Information)

. dedicated : PGA에 Stack과 UGA가 위치한다.
. share : PGA에 Stack만 올라가고, UGA는 SGA에 위치하는데, UGA가 SGA에 상주하면 share pool의 공간이 좁아지므로 실질적으로 UGA는 large pool에서 돌아간다.
 
. PGA 관리
세개의 파라메터로 PGA의 크기를 관리할 수 있다.

. WORKAREA_SIZE_POLICY
MANUAL로 설정할 경우 : SORT_AREA_SIZE  파라메터를 이용하여 정렬공간을 설정한다.
AUTO로 설정할 경우 : PGA_AGGREGATE_TARGET 파라메터를 이용하여 PGA의 크기를 설정한다.

. SORT_AREA_SIZE : PGA에서의 sort는 기본적으로 memory sort인데, PGA의 sort공간이 부족하여 디스크의 temporary공간에서 sort하는 것을 disk sort라 하는데 이는, I/O발생이 빈번하여 속도가 저하되므로, MENUAL로 설정하여 직접 sort size의 크기를 늘려 I/O발생이 빈번하지 않도록 설정한다.

. PGA_AGGREGATE_TARGET : 모든 세션의 PGA 크기의 합을 설정하는 파라메터이다. (user 한명의 PGA가 아닌 모든 user의 PGA크기를 관리!!)
 
. PGA의 크기 확인
SELECT addr, username, pga_used_mem, pga_alloc_mem, pga_max_mem FROM v$process
. PGA_USERD_MEM:프로세스가 현재 사용하는 PGA의 크기
. PGA_ALLOC_MEM: 프로세스에 할당된 PGA의 크기 (사용 완료 후 시스템 메모리에 반환하지 않는 메모리 포함)
. PGA_MAX_MEM:프로세스가 사용한 최대 PGA의 크기

:
Posted by Elick
2011. 1. 14. 15:31

External Table Work/ORACLE2011. 1. 14. 15:31

Overview
Oracle 9i 이상
Table이 Database 내부의 Tablespace가 아닌 Database 외부의 OS 파일로 존재하게 하는 기능.
흔히 DW(Data Warehousing) 환경에서 기본적인 ETL(Extraction, Transformation, Loading) 작업에 사용.
주로 SELECT 만 사용하게 됨.
CREATE TABLE ... ORGANIZATION EXTERNAL 구문을 사용하여 생성하기는 하지만, 실제로 Table이 생성되는 것은 아니다.
External Table은 어떤 extents 와도 관련이 되어 있지 않다.
External Data에 접근하려면 Data Dictionary 에 metadata를 생성해야 한다.

문법
SQL> CREATE TABLE table_name ORGANIZATION EXTERNAL ...
External Table에 데이터를 처음 Unload 하게 되면, 자동으로 Select 문장의 데이터타입을 기준으로 metadata가 생성된다.

External Table 생성 방법
ORACLE_LOADER
: external 파일의 데이터를 읽어오는 기능. SQL*Loader 의 문법을 따른다.
ORACLE_DATAPUMP
: external 파일에 데이터를 쓰는 기능을 하고, 이를 다시 Database에 다시 reload 한다. 
Database로부터 데이터를 읽고 External Table에 insert 한다.
(... 사실 이렇게 External Table을 사용해 본 경험이 없다...)

External Table의 장점
병렬 SQL 수행가능
Table로 Loading 불필요
Storage 절약
Virtual Read-only Table*
External regular table 간 조인가능

External Table의 단점
index 생성 불가
Join 이나 Filter 수행이 어려움

[예제]
-- Oracle Directory 로 만들 경로 결정 혹은 생성
-- Oracle Directory 생성
        CREATE OR REPLACE DIRECTORY <oracle directory name> AS '<path>';
        GRANT READ, WRITE ON DIRECTORY <oracle directory name> TO <account>;
-- External Table 생성
CREATE TABLE et_ora_ext_t (
        col1 varchar(10)
        .
        .
        .
)
ORGANIZATION EXTERNAL
  (  TYPE ORACLE_LOADER -- 생성 방식 지정 (ORACLE_LOADER / ORACLE_DATAPUMP)
     DEFAULT DIRECTORY <directory>
     ACCESS PARAMETERS 
       ( records delimited by newline
        badfile D_ORA_EXT_TXT:'et_ora_ext_t.bad'
        logfile D_ORA_EXT_TXT:'et_ora_ext_t.log'
        fields terminated by ',' -- 컬럼 구분자로 사용할 문자
        missing field values are null -- 데이터가 없으면 null 로 입력
                 )
     LOCATION (D_ORA_EXT_TXT:'et_ora_ext_t.txt') -- <oracle directory name> 내의 데이터 파일이름.
  )
REJECT LIMIT UNLIMITED
PARALLEL -- 병렬처리 여부 (PARALLEL | NOPARALLEL)
;

SELECT * FROM et_ora_ext_t;

--ALTER EXTERNAL TABLE
ALTER TABLE et_ora_ext_t REJECT LIMIT 100;
ALTER TABLE et_ora_ext_t PROJECT COLUMN REFERNCED;
ALTER TABLE et_ora_ext_t PROJECT COLUMN ALL;
ALTER TABLE et_ora_ext_t DEFAULT DIRECTORY admin_dat2_dir;
ALTER TABLE et_ora_ext_t ACCESS PARAMETERS (FIELDS TERMINATED BY ';');
ALTER TABLE et_ora_ext_t LOCATION('et_ora_ext_t2.txt', 'et_ora_ext_t3.txt');
-- PARALLEL, ADD COLUMN, MODIFY COLUMN, DROP COLUMN, RENAME TO 는 일반 테이블변경방식과 동일함.

-- 일반 테이블을 삭제하는 것과 같지만, DB 외부의 실제 데이터는 삭제되지 않고, DB 내의 metadata 만 삭제된다.
-- DROP EXTERNAL TABLE
DROP TABLE admin_ext_employees;
:
Posted by Elick
2011. 1. 6. 17:37

Archive Mode vs No-Archive Mode Work/ORACLE2011. 1. 6. 17:37

[No-Archive Mode]
처음 설치시 기본적으로 No-Archive.
사용자의 모든 변경정보가 Redo Log File에 Backup되기 때문에 Redo Log File의 크기와 개수가 Backup할 수 있는 Data의 크기를 좌우.
Redo Log File이 아주 오래 전의 복구 Data를 가지고 있지 않다면 복구를 할 수 없는 단점.
Oracle Server는 사용자들이 입력, 수정, 삭제작업을 수행할 때 마다 발생하는 모든 변경 전 Data와 변경 후 Data들을 Redo Log Buffer 영역에 Backup.
LGWR Background Process는 Redo Log Buffer의 Data들을 영구히 저장할 수 있는 Redo Log File로 저장.
기본적으로 Oracle에서는 3개의 Redo Log File을 제공.
세 번째 Redo Log File도 모두 사용되고 나면, 더 이상 제공되는 Redo Log File이 없기 때문에 다시 첫 번째 Redo Log File에 Backup Data들을 저장.
이 때문에 이전 Backup Data들은 모두 유실되는 문제가 발생.

[Archive Mode]
모든 복구 Data를 가지고 있으며 Database에 문제가 발생했던 시점까지 복구할 수 있는데 이러한 방법을 완전복구하고 한다.
반대로, 복구할 수 있는 Data가 Backup되지 있지 않다면 문제가 생겼던 시점까지 복구할 수 없는데 이러한 방법을 불완전 복구라 한다.
Database에서 발생하는 모든 Data(변경 전 Data와 변경 후 Data)들이 ARCH Process에 의해 항상 Backup되는 Mechanism을 Archive Mode(Archive Mode)라고 한다.
기본적으로 Oracle Database는 No-Archive Mode이며 설치 후 Archive Mode로 전환하는 작업을 수행하는 것을 권고한다.

[Off-Line Backup : Cold Backup, 전체 Backup]
반드시, 정상적인 종료 Option(NORMAL, TRANSACTIONAL, IMMEDIATE)을 사용하여 Oracle Server를 종료.
Oracle Database와 관련된 모든 File (Data File, Control File, Redo Log File, Prameter File)을 같은 시점에 운영체계 명령어를 사용하여 Disk 또는 Tape 장치에 복사.
Off-Line Backup 방법은 No-Archive Mode, Archive Mode 둘다 수행할 수 있다.

[Archive Mode 전환 방법]

* 환경설정
init.ora File에 Archive Mode와 관련된 Prameter를 설정
[LOG_ARCHIVE_START] : ARCH Background Process에 의해 Database를 Archive Mode로 전환. Log switch가 발생하면 자동으로 Archive를 실행
[LOG_ARCHIVE_DEST] : Prameter는 Redo Log File에 대한 Archive File이 생성될 기본 저장 경로를 의미
[LOG_ARCHIVE_DEST_n] : Prameter는 Archive 경로를 여러 군데 지정할 때 사용. 최대 10개
[LOG_ARCHIVE_FORMAT] : 생성될 Archive File의 File 포맷을 결정

Database를 Archive Mode로 전환하기 위해서는 Database를 다시 시작해야 하며, MOUNT 단계에서 명령어를 실행해야 한다.
Archive Mode로 전환 : ALTER DATABASE ARCHIVELOG;
No-Archive Mode로 전환 : ALTER DATABASE NoArchiveLOG;
Archive Mode 확인 : ARCHIVE LOG LIST;
:
Posted by Elick