Database Background Process Instance Parse Execute Fetch Server


Database의 구조 Background Process Instance Parse Execute Fetch Server Process Shared Global Area(SGA) Shared Pool Java Pool Library Cache Database Buffer Cache Redo Log Buffer Row Cache Snnn Dnnn RECO Pnnn Large Pool Streams Pool Program Global Area (PGA) PMON SMON DBWR CKPT LGWR LMS ARCH SNPn User Process Application Program SQL*Plus Database Data Files Redo Log Files Control Files Archive log Files Offline Storage Device Parameter Files Backup Files password Files Alert log Files Trace Files


SGA(Shared Global Area) Shared Global Area(SGA) Shared Pool Library Cache Database Buffer Cache Data Dictionary Cache Database Buffer Cache DBWR Server Process Database SQL DATA User Process Data Files 4

Background Process Instance Shared Global Area(SGA) Shared Pool Java Pool Database Buffer Cache Library Cache Data Dictionary Cache Redo Log Buffer Large Pool Streams Pool PMON SMON DBWR CKPT LCKn Pnnn SNPn RECO Snnn DBWn ARCH Dnnn LGWR Database Data Files Control Files Redo Log Files Archive log Files 5

Background Process Checkpoint Dirty buffer threshold reached No free buffers Timeout RAC ping request Tablespace offline Tablespace read only Table DROP or Truncate Tablespace begin backup DBWR • Data block buffer cache SMON • System 감시 Shared Global Area • Instance 복구 • Dictionary Cache • Temporary Segment 제거 • Data File Write LGWR PMON • Redo Log Buffer의 내용 을 Online Redo Log File 에 기록 • 프로세서 감시 • Fail User Process 정리 • Lock 해제 CKPT At commit When one-third full When there is 1 MB of redo Every three seconds Before DBWR Writes • 변경된 모든 block을 data file에 쓰도록 유도 • 체크포인트 기록 발생 시 SGA buffer cache에 있는 모 든 dirty buffer를 disk에 기록한다. • Online Redo Log File이 채워지면 자동적으로 실행 6


물리적인 Database 구조 Database name and identifier Time stamp of database creation Tablespace names Names and location of data file and redo log files Current redo log file sequence number Checkpoint information Begin and end of undo segments Redo log archive information Backup information Data File • 사용자 프로세스가 빈버퍼를 찾지 못하고 버퍼의 임계점에 도달하 면 프로세스는 LRU목록 검색을 중지하고 DBWR에 신호를 보내 Dirty Buffer를 Data File에 기록한 다. • 모든 Oracle Database는 하나 이 상의 Datafile을 가지며 DB의 영 역이 부족할 때 자동으로 확장할 수 있는 기능이 있다. INSTANCE Parameter Files Backup Files • Data File과 Redo Log File의 위치 • DB 생성시간 • Instance가 시작될 때마다 Database와 Redo Log File 지 정 Redo Log File • Redo Log Buffer의 내용을 기록 • System failure에 대한 복구수단 제공 • Cycle방식으로 사용됨 Called a log switch Checkpoint operation also occurs Information written to the control file Control File • 일반사용자가 수정 할 수 없는 binary file • Database header 정보 현재 상태 저장 • File이 다 차면 Archive 됨 password Files Alert log Files Trace Files Archive Log Files 8



데이터베이스 시작과 종료 SQL> startup ORACLE instance started. Total System Global Area 30901048 Fixed Size 729912 Variable Size 25165824 Database Buffers 4194304 Redo Buffers 811008 Database mounted. UP Database opened. T R bytes bytes OPEN MOUNT A Data files and ST Control file open Log files open N W O NOMOUNT TD U SH Instance create Init file open SHUTDOWN STARTUP NOMOUNT 11 ALTER DATABASE MOUNT; ALTER DATABASE OPEN;







저장 영역 설정 옵션 CATEATE TABLE emp ( empno NUMBER(4) …, ………… ) TABLESPACE AAAAA STORAGE ( INITIAL 200 K NEXT 200 K PCTINCREASE 50 MINEXTENTS 5 MAXEXTENTS 20 FREELISTS 2 FREELIST GROUPS 2 ) PCTFREE 20 PCTUSED 50 INITRANS 5 18 MAXTRANS 10; 18


사용자 테이블스페이스 생성 System T. S s. dbf RBS T. S Temp T. S t. dbf PRODUCT T. S r. dbf p 1. dbf SALES T. S s 1. dbf 20 s 2. dbf CREATE TABLESPACE product DATAFILE ‘/…. /p 1. dbf’ SIZE 1000 M; CREATE TABLESPACE sales DATAFILE ‘/…. /s 1. dbf’ SIZE 500 M, ‘/…. /s 2. dbf’ SIZE 500 M DEFAULT STORAGE( INITIAL 200 K NEXT 200 K PCTINCREASE 50 MINEXTENTS 5 MAXEXTENTS 20 FREELISTS 2 FREELIST GROUPS 2 );



Auto Commit • Commit이 자동으로 일어나는 경우 – DDL – Create, Alter, Drop, Rename, Truncate등을 사용 • Commit이 자동으로 일어나지 않는 경우 – DML – Insert, Delete, Update를 사용할 경우



Transaction(Cont) • COMMIT 된 후 – 관련된 Rollback Segment에 대한 내부 Transaction Table은 Transaction이 Commit되 었다는 사실을 기록하고 Transaction에 대응되는 고유한 시스템 변경 번호가 할당되며 테이블에 기 록 – LGWR은 SGA의 Redo Log Buffer에 있는 Redo Log 입력 항목을 온라인 Redo Log File에 기록. 또한 LGWR은 Transaction의 SCN을 온라인 Redo Log File에 기록 – 행과 테이블에 적용되는 Lock을 해제. Transaction을 “Complete”로 표시




Savepoint 예 INSERT INTO AA VALUES(1); INSERT INTO AA VALUES(2); INSERT INTO AA VALUES(3); SAVEPOINT SP 1; DELETE FROM AA WHERE SEQ=3; COMMIT; ----- (1) ? ? DELETE FROM AA WHERE SEQ=2; SAVEPOINT SP 2; ROLLBACK TO SP 1; //3건의 데이터 조회 (1, 2, 3) ROLLBACK TO SP 2; //3건의 데이터 조회 (1, 2, 3) (1) 위치 삽입할 경우, ROLLBACK TO SP 2해도 삭제된 SEQ=3 데이터는 복원되지 않음 30
- Slides: 30