Top Banner
New Features for Administrators (Oracle8) Oct, 2000 CloudBox Jang Kyung Sang
122

Oracle History #4

Nov 20, 2014

Download

Education

Kyung Sang Jang

Oracle New Features for Version 8
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Oracle History #4

New Features for Administrators(Oracle8)

Oct, 2000

CloudBox

Jang Kyung Sang

Page 2: Oracle History #4

Oracle8 New Features http://www.ggola.com

Oracle Server Position

Understanding the figure

Course

1. Using Partitioning2. Implementing Partitioned Indexes3. Commands and Guidelines for Partitioned Tables and Indexes4. Parallelizing Insert, Update and Delete Operations5. Identifying New Rowid Structure6. Defining Object Relational Features7. Managing Large Objects8. Implementing Oracle Advanced Queuing9. Using Additional New Features10. Introduction to Recovery Manager (RMAN) 11. Advanced RMAN12. Enhancements to Networking13. Implementing Password Management14. Migration Server and Applications

[email protected] - 2 - 장 경상

Application

Tool

s

SQL, PL/SQL

Oracle8

Operating/ System

Clie

nt

Clie

nt Clie

nt Clie

nt

Clie

nt

Clie

nt

* ORACLE8 특징

VLDB Solution :

- partition, rman

OLTP Solution :

- Advanced Queuing, Net8

Object Solution :

- method

Page 3: Oracle History #4

Oracle8 New Features http://www.ggola.com

1. Using Partitioning

Why?

VLDB for very large database (수백 기가에서 테라까지)

Availability

Management

Scalability

What is Partition?

Sample script

Partitioned tables and indexes

- They can be decomposed into smaller pieces called partitions.

- A range of key values를 기반으로 partition

- VLDB 환경에 유용하다.

- Supports up to 64,000 partitions per single table or index(1개의 table or index가 64,000개까지의 segment로 구성될 수 있다)

Attribute

- 동일 table or index의 partition별 columns, datatypes등 partition의 logical attribute는 항상 일치 해야 한다..

[email protected] - 3 - 장 경상

create table order (ord_year number(4), ord_month number(2), ord_day number(2), ord_id number(10)) partition by range (ord_year, ord_month, ord_day)(partition p1 values less than (1997, 07, 01) tablespace data01, partition p2 values less than (1997, 08, 01) tablespace data02, partition p3 values less than (1997, 09, 01) tablespace data03 ) partition p4 values less than (MAXVALUE,MAXVALUE,MAXVALUE) tablespace data04)

Page 4: Oracle History #4

Oracle8 New Features http://www.ggola.com

- But partition별 storage는 다양하고 서로 다르게 설정할 수 있다.

Components

- partition key : partition을 구분할 key가 되는 column으로최대 16개 까지 composite key 가능하지만 나중에 alter로 column modify할 수는 없다.

- values less than : 상수만 사용이 가능하며 유일한 사용가능 function은 TO_DATE, RPAD 뿐이다.(value 중간에 빠지는 값은 안된다. 예를 들어 1~3, 5~6, 8~9 처럼 중간에 4나 7을 임의로 뺄수는 없다)

- physical attributes : partition별 storage를 다르게 설정할 수 있다.CF. table partition과 index partition은 별개의 문제이므로 partition 구성은 서로 영향을 주지 않는다.

- Long, Long Raw, LOB Type은 partition table을 지원하지 않는다. (ORA-14085 error 발생)

Using Partition

Values less than

- values less than 에서 지정한 value는 자기 값을 포함하지 않는다. CF. values less than (5) 라면 5보다 작은 값을 지정한다.

- Insert하려는 value가 가장 큰 값의 partition bound와 동일하거나 크면 실패한다.CF. last partition에 지정된 value에는 사실 implicit check constraint가 적용된다. (Data Dictionary에는 기록되지 않음)

- Last Partition에 value 대신 MAXVALUE Key word를 사용하여 이전 partition value를 제외한 나머지 모든 값에 대한 insert를 허용할 수 있다. (NULL을 포함할 수 있다)CF. NULL value는 모든 values보다 큰 sort값을 갖으므로 maxvalue key word를 사용해야만 insert가 가능하다.CF. maxvalue key word를 사용하면 implicit check constraint를 사용하지 않는다.CF. 2개 이상의 columns로 partition key가 이루어 져도 maxvalue key word를 사용할 수 있지만, last partition이 아니라면 첫번째 key column에는 사용할 수 없다.

[email protected] - 4 - 장 경상

Page 5: Oracle History #4

Oracle8 New Features http://www.ggola.com

- update를 통해 partition key에 해당하는 data를 수정시 그 변경된 값이 partition을 이동해야 한다면 ORA-14402 error를 받을 것이다. 즉, 이런 경우에는 해당 data를 delete한 후 다른 partition으로 insert를 해야한다. (Oracle8i부터 해결)

Multicolumn partitioning

- 2개 이상의 column들로 partition key를 구성할 수 있으며 최대 16개까지 가능하다. CF. Date를 나타내기 위해 년, 월, 일로 column을 나누어 정하여 partition key로 사용하는 경우도 있다.

Equipartitioned Tables and Indexes

- 동일한 logical partitioning attributes를 갖는 두개 이상의 objects에 대해 equipartition이 가능하다.

- Prerequisite : 1. Same number of partitions2. Same values less than boundaries3. Same number, datatype(length, precision, scale)

- Consideration point : 1. Using equipartitioning reduces the downtime and the amount of data that is unavailable during partition maintenance operations and tablespace recovery operations.2. Data-management time is relative to partition sizes.3. Other unaffected partitions can be accessed at the same time.4. table과 그 index들이 equipartition 되면, the effect of move PARTITION can be limited to one table partition and the corresponding index partitions

- Generally PK 대 FK tables 혹은 Table 대 PK Index로 equipartition구성할 때 효과적이다.

[email protected] - 5 - 장 경상

AccountAccount_no

PK

FK

Same Partition

Page 6: Oracle History #4

Oracle8 New Features http://www.ggola.com

Using Advanced Partition

Partition Extended Table Names

- partition으로 구성된 table을 사용할 때 그 table의 특정 partition만을 지정해서 사용할 수 있다. 즉, DML을 구사할 때에 table name 옆에 partition을 지정함으로써 특정 partition에서만 select, insert, update, delete가 가능해 진다. select * from account PARTITION(PART03) where …. ;

- 단, 이러한 특정 partition을 지정하는 DML은 PL/SQL이나 DB Link와 같이 remote access를 하는 경우 인식할 수 없다. 따라서 이런 경우에는 partition별로 view를 만듦으로써 원하는 작업결과를 얻을 수 있다. 이들 view는 partition별로 지정이 가능할 뿐만 아니라 각각의 단위 별로 grant도 다르게 줄 수 있다.

Parallel DDL

- partition을 다루는 다음과 같은 command들도 Parallel 처리를 지원한다. CREATE (partition) INDEX CREATE (partition) TABLE AS SELECT ALTER TABLE MOVE PARTITION ALTER TABLE SPLIT PARTITION ALTER INDEX REBUILD PARTITION

- 일반적으로 different operation마다 different parallelism이 사용되는데, create table as select 와 create index는 partition별 동일한 a degree of parallelism을 사용한다.

DML Partition Locks

- DDL이나 partition별 operation의 원할한 사용을 위해서 Oracle8은 partition independence를 지원하다. 즉, partition별 Locking처리가 가능하다.

- Partition Lock은 Table Lock 과 Row Lock 사이의 중간단계에 위치하는 Lock으로 정의될 수 있고, 이는 동일 table에 여러 user들이 concurrently access시 partition

[email protected] - 6 - 장 경상

CheckAcct_no

Acct < 100 Acct < 200 Acct < 300 Acct < …n

Page 7: Oracle History #4

Oracle8 New Features http://www.ggola.com

data를 보호 하는데 그 목적이 있다.CF. partition lock은 table처럼 S, X, SS, SX, SSX Lock mode가 있다.

- Table and Partition Locks are acquired at different times.1. Table Lock은 parsing에서 결정되고 execution시(cursor start) 획득된다.2. Partition Lock은 execution시 결정되고 획득된다.(bind variable은 실행 시 결정되기 때문이고, 또한 partition key 이외의 값으로 SQL문이 생성되는 경우가 많기 때문이다. 물론, 명시적으로 partition key 값을 비교하도록 구성한다면 그 경우 partition lock도 parsing시 결정되고 execution시 획득될 것이다.3. OPS(Oracle Parallel Server)에서는 table locks 이나 partition locks 모두 performance에 영향을 줄 수 있기 때문에 'DML_LOKCS=0' parameter를 사용하거나 특정 table에 대하여 'ALTER TABLE table_name DISABLE TABLE LOCK' command를 사용 함으로써 performance 향상을 꾀 할 수 있다. 단, 이런 경우 DDL command를 사용할 수 없다.

Operations

One-step Operation

1. ALL DDL은 one-step operation이지만, ' CREATE INDEX' or 'ALTER TABLE REBUILD INDEX'의 경우는 예외다.

2. Alter table add column 같은 dictionary operation은 매우 빠르게 진행되고 exclusive dictionary lock과 함께 DML Lock을 잡고 other operation을 허용하지 않는다.CF. queries can be run simultaneously

Three-step Operation

1. Read dictionary while holding share dictionary locks

2. Acquire share lock on a table or partition, release the dictionary locks, and scan and update the table partition or index partition

3. Acquire exclusive dictionary locks and update the dictionary while holding exclusive locks

CF. long running operation이지만, less restrictive DML locks이어서 running중 other operation이 가능하다. Affected partition만 exclusive mode로 잡힌다, Table is locked in shared mode.

[email protected] - 7 - 장 경상

Page 8: Oracle History #4

Oracle8 New Features http://www.ggola.com

CF. 이들 operation을 일으키는 command는 : 'Alter Table: Drop/Modify/Move/Split/Exchange Partition' 'Rebuild Unusable (local indexes)' ' Create Index (global indexes)' 'Alter Index Rebuild Partition(global indexes)' 'Direct Path Load Table Partitions'

Benefits of Partitioning

High Availability

- backup and restore operation을 비롯하여 query나 DML시 동일 table이나 index를 사용하는 다른 partition에 영향을 주지 않는다. 즉, Partition별로 management 된다.

one partition이 unavailable이어도 other partitions can be used.

Ease of Administration (Manageability)

- tablespace간에 partition move가 가능하고 partition별 drop, add, truncate도 할 수 있다.

- partition은 a user-defined value로 나누어질 수 있다.

- DML을 table level 대신에 partition level로 사용할 수 있다.

- partitions을 다루기 위한 a variety command를 제공한다.

commands : Alter Table (Add/Drop/Truncate/Move/Split/Exchange) Partition

Improved Performance

- Optimizer는 scan에 필요하지 않는 partition은 작업하지 않는다.

- Partition은 parallel로 scan될 수 있고 또한 parallel로 insert, update, delete될 수 있다.

- sort를 위한 temporary area size가 감소한다.

- partition을 physical devices에 나눔으로써 load-balance가 가능하다.

- MPP 환경에서 CPU-disk affinity control이 가능하다.

[email protected] - 8 - 장 경상

Page 9: Oracle History #4

Oracle8 New Features http://www.ggola.com

- OPS에서 특정노드에 대해 data의 ownership을 강제할 수 있다.

[email protected] - 9 - 장 경상

Page 10: Oracle History #4

Oracle8 New Features http://www.ggola.com

2. Implementing Partitioned Indexes

Partitioned Indexes

Index Strategy

- Index는 partitioned index 와 non-partitioned index 로 나누어지며 DBA와 개발자의 요구에 맞도록 선택해야 한다.(단, cluster index는 partition될 수 없다)

- Index strategy를 위한 고려대상1. Type of access to data through the applications2. Performance in accessing data3. Availability in case of disk failure4. Are parallel operations possible ?

Types of Indexes

Oracle8 supports four types of indexes.

Availability, Performance, Manageability

Prefixed Indexes

- Partition Key의 columns들과 Index의 leftmost columns은 same order and number of columns 가 되어야 한다.

- 이 Index가 Unique Index로 구성된다면 이 data를 가져오기 위해선 하나의 partition만 access할 것이다. 물론, nonunique index라도 where절의 조건에 partition key에 해당되는 column이 모두 기술된다면 역시 하나의 partition만 access할 것이다.

Nonprefixed Indexes

[email protected] - 10 - 장 경상

create index glob_orders on orders (ord_year, ord_month, ord_day) global partition by range (ord_year, ord_month, ord_day) ( partition p1 values less than (1997,08,16) tablespace index01, partition p2 values less than

create index loc_nonpre_orders on order (ord_id) local ;

Page 11: Oracle History #4

Oracle8 New Features http://www.ggola.com

- partition key와 동일한 columns을 leftmost columns으로 하지 않는 Index는 모두 nonprefixed index다.

- Unique nonprefixed index는 index key부분으로 partition key를 포함해야 하며, data를 가져오기 위해선 하나의 partition만 access할 것을 보장해야 한다.

- Nonunique nonprefixed indexes는 data를 가져오기 위해서 all partitions을 scan해야 한다.

Global / Local Indexes

1.Nonpartitioned indexes : Just Global Index

2.Global prefixed indexes : Index Key Column과 Partition Key의 leftmost가 같지만 underlying table과는 별개이다. 물론 underlying table과 key를 동일하게 만들 수도 있지만 equipartition 되지 않는다. 즉, global은 global이다.

3.Local prefixed indexes : Partition Key의 columns이 Index의 leftmost columns 과 일치한다.

4.Local nonprefixed indexes : Partition Key의 columns이 Index의 leftmost columns 과 일치하지 않는다.

Global Prefixed Indexes

- Normally, 기초 table partition과 동일한 equipartitioned index가 아니다. 물론, 강제로 equipartitioned index로 만들 수는 있으나 Oracle은 이러한 경우 equipartitioning 관리를 자동으로 해주지 않으며 SQL plan 설정할 때에도 무시되므로 equipartitioned index는 반드시 Local로 만들자. 즉, 강제로 key를 일치시켜도 global index이므로 partition independence를 지원하지 않는다.

- Unique or Nonunique 모두 가능하며, The highest partition은 maxvalue를 partition bound로 가져야 한다. 즉, 'MAXVALUE'가 꼭 지정되어야 한다.

[email protected] - 11 - 장 경상

create index glob_orders on orders (ord_year, ord_month, ord_day) global partition by range (ord_year, ord_month, ord_day) ( partition p1 values less than (1997,08,16) tablespace index01, partition p2 values less than

Page 12: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 일반적으로 global index는 local index보다 관리가 더 어렵다. 왜냐하면, 대상 table의 partition이 수정되면 global index는 전 partition이 영향을 받기 때문이다.

Local Prefixed Indexes

- All rows in a table partition have a corresponding index entry in the index partition. (partition key의 leftmost columns는 index 되어야 한다)CF. 만일, name and location을 지정하지 않으면 대상 table의 partition name과 똑같이 만들어지고 default tablespace에 index data가 생성될 것이다.

- Local Index는 각 partition별 maintenance operation이 가능하므로 maintenance operation 동안 다른 partition에 대한 concurrently SELECT and DML이 가능하다.

- MPP platforms에서의 parallel processing의 강점을 갖는다.

- Unique or Nonunique 모두 가능하다.

Local Nonprefixed Indexes

- Nonunique일 수 있다.

- Partition key가 index key의 subset일 때에만 unique가 가능하다.

※ table partition key에 포함 되지않은 columns에 대한 query의 fast access가 필요한 경우 유용하다.

prefixed VS nonprefixed indexes : prefixed index는 queries and DML시 access할 only one partition에 대해 작업을 진행하지만, nonprefixed index는 n개의 partition 즉, 몇 개가

[email protected] - 12 - 장 경상

create unique index loc_pre_orders on orders (ord_year, ord_month, ord_day, ord_id)local ( partition p1 tablespace index01, partition p2 tablespace index02, partition p3 tablespace index03 ) ;

create index loc_nonpre_orders on orders (ord_id)local( partition p1 tablespace index01, partition p2 tablespace index02, partition p3 tablespace index03 );

Page 13: Oracle History #4

Oracle8 New Features http://www.ggola.com

될지 모르는 partition에 대해 작업을 진행하므로 prefixed index의 효율이 더 좋다.

Partition index

global과 local을 어떻게 결정할 것인가?

local에서 prefixed 와 nonprefixed를 어떻게 결정할 것인가?

CF. local prefixed index : best performance, availability, manageability

1.Table partition key 와 index partition key의 leftmost columns이 일치 하는가 ? local prefixed index

2.그렇지 않다면, unique index on a nonpartitioning column ? Global prefixed index

3.그렇지 않다면, manageability의 효율보다 higher availability를 위해 performance overhead를 감수할 것인가 ? Local nonprefixed index

4.그렇지 않다면, DSS system 인가? Local nonprefixed index

5.OLTP 인가? Global Prefixed index

Index Unusable(IU)

- Import partition or conventional path SQL*Loader는 local index maintenance를 bypass할 수 있는 option을 제공한다. 이런 경우 import가 끝나면 관련된 local index partition은 IU로 mark된다. 즉, index unusable로 설정된다.

- Direct path SQL*Loader 또한 작업이 complete successfully 되지 않으면 local index partitions and global indexes도 IU가 된다.

- ROWID에 변경을 주는 alter table move partition command도 관련 local and global index partition을 IU로 만든다.

CF. 기타 : alter table truncate partition global index partition IU alter table split partition local index partition IU alter index split partition index partition IU

[email protected] - 13 - 장 경상

OLTP

X

GOOD

DSS

LOCALGLOBAL

PREFIXED

NONPREFIXED

PQ option 유용

Unique data 유용

Page 14: Oracle History #4

Oracle8 New Features http://www.ggola.com

- IU상태가 된 partitions은 그 partition을 사용하는 queries or DML이 execute 되기 전에 rebuild 하라. (IU가 아닌 다른 partition index data는 여전히 유효하므로 IU partition외의 data를 scan하는 작업은 이상이 없을 것이다.

- IU 상태가 된 nonpartitioned indexes는 drop 후 re-create 해야 사용할 수 있다.

Parallel scan

Parallel table scan

SQL> select /*+ PARALLEL(EMP, 9) */ * from emp ;

- ROWID에는 partition numbers가 기록되므로 parallel table scan은 rowid를 통해서 이루어진다.

- 기존 버전에 존재하던 Parallel Query를 위한 process들은 이제 rowid에 의해 각 partition별로 나누어져서 작업을 처리하게 될 것이다.

Parallel index scan

SQL> select /*+ PARALLEL (I2, 3) */ * from emp where person = 'a' ;

- Index partition별로 different slaves를 사용하여 index scan이 parallel로 가능해진다. (위의 예는 I2라는 index가 3개의 partition으로 구성된 partitioned index라는 예측을 가능케 한다.)

- Parallel query slaves는 partitions 수만큼 지정할 수 있다. 즉, 하나의 partition에는 maximum 하나의 slave만 가능하다.

[email protected] - 14 - 장 경상

Page 15: Oracle History #4

Oracle8 New Features http://www.ggola.com

3. Commands and Guidelines for Partitioned Tables and Indexes

Alter command for partitions

Alter table drop partition

SQL> alter table order drop partition p1 ;

- this command는 table order에서 partition p1을 remove하고 그 안에 존재하던 data까지 동시에 삭제한다.

- 이런 명령은 주기적으로 없어지는 old data를 가지는 historical data 관리에 유용하다.CF. if partition을 drop하고 그 안의 data는 살리고 싶다면 해당 partition을 adjacent partition에 merge함으로써 해결할 수 있다.CF. if data를 dropped partition에 insert하려하면, dropped partition보다 바로 높은 value의 partition에 자동으로 저장되겠지만, 만일 dropped partition이 해당 table의 highest partition이면 거기에 해당되는 insert는 fail될 것이다.

- 또한, this command는 해당 local index의 partition도 함께 drop시킬 것이다. (해당 index의 status가 IU 이건 아니건 상관없이)

- if global index가 정의되어 있는 table의 data가 들어있는 partition을 drop하는 경우, all global indexes partition은 IU 상태가 될 것이다. 따라서 이런 경우 index rebuild를 해야 하는데 만일 rebuild하기가 싫다면 partition을 drop하기 전에 drop할 partition에 있는 모든 data를 delete로 일일이 제거하고 나서 그때 partition을 drop해야 한다.

Partition drop or Row delete

partition을 drop할 것인가 row를 delete할 것인가.

- global index의 지속적인 사용 즉, availability가 가장 중요하다면 partition drop보다는 rows를 delete하라.

- table에 global index가 많거나, drop되는 partition의 row수가 전체 total row수에 비해 적은 portion을 차지한다면, Row delete가 global index rebuild 보다 cost가 적을 것이므로 partition drop보다는 row delete를 선택하라.

[email protected] - 15 - 장 경상

Page 16: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 위와 반대의 경우 즉, global index의 수가 적거나 delete할 data가 상당히 많다면 오히려 partition drop후 global index rebuild가 더 적은 cost를 발생시킬 것이다.

- table의 FK가 enable되어 있고 partition에 data가 있다면 drop partition은 error가 날 것이다. 이런 경우 FK를 delete하던가 아니면 row delete 후 partition을 drop해야한다. 또한 table이 하나의 partition으로 구성되어 있을 때에도 partition drop은 할 수 없고 table을 drop해야 한다.

Alter index drop partition (allowed for global indexes only)

SQL> alter index order_idx drop partition p1 ;

- this command는 partition을 remove하고 partitioned global indexes로부터 그 안에 존재하는 index entries를 모두 삭제한다. 이 작업은 index I/O load를 rebalance하는데 사용될 수 있다.

- This command는 global index에만 유효하며 local index partition은 explicitly drop할 수 없다. 또한 the highest partition은 drop할 수 없다.

- partition을 drop하면 value boundaries는 the next highest partition에 merge된다. 또한 dropped partition에 해당되는 data가 insert되면 바로 the next higher partition에 저장된다. 만일 data를 가진 partition을 drop했으면 the next highest partition은 IU status가 되고 반드시 rebuild해줘야 사용할 수 있다.CF. IU status의 partition도 drop될 수 있다.

table or index partition의 name을 바꿀 수 있다. 물론, index의 경우 IU status partition도 name change에는 아무 상관이 없다.SQL> Alter table order rename partition p1 to old_p1 ;SQL> Alter index order_idx rename partition IX_p1 to old_IX_p1 ;

Alter table add partition

SQL> alter table order add partition p4 values less than (1998, 09, 01) tablespace data04 ;

- this command는 오직 the high end of the table에 partition을 add할 때에만 사용될 수 있다. 따라서 partitioning key columns value가 단조롭게 증가하는 형태에 유용하다.CF. table의 시작이나 중간에 partition을 추가하고 싶으면 'SPLIT PARTITION' command를 사용하라.

[email protected] - 16 - 장 경상

Page 17: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 만일, 가장 마지막 partition즉 high partition의 the first element 가 'MAXVALUE'를 사용했으면 이 때에도 add partition은 할 수가 없다. 이런 경우에도 split partition을 이용하여야 한다.CF. 물론, the high partition의 첫번째가 아닌 the second element 이상의 값에서 'MAXVALUE'를 사용한 경우는 add partition은 문제없이 수행이 된다.

- 이런 add partition은 관련 local index에 a matching partition 또한 추가하는데 그 이름은 table partition의 그것과 동일하다. Physical storage는 the base index의 것을 default로 사용하며 또한 added partition of the underlying table 과 동일한 tablespace에 위치한다.CF. 위 내용은 Global Index에는 적용되지 않으며 Index Partition의 status가 IU라도 상관없이 add partition은 가능하다.

table or index partition을 modify 할 수 있다. SQL> Alter table order modify partition p1 storage (maxextents 512) ;partition별 table의 physical storage를 변경할 수 있다.(move partition command로 partition을 다른 tablespace로 옮길 수 있다)SQL> Alter index order_idx modify partition IU_p1 storage (maxextents 512) ;SQL> Alter index order_idx modify partition IU_p1 unusable ;global or local partitioned index에 대하여 partition별 physical storage를 변경할 수 있다.(rebuild partition command로 partition을 다른 tablespace로 옮길 수 있다)(UNUSABLE Index는 rebuild나 drop and re-create로 USABLE로 만들 수 있다)

Alter table/index modify physical attributes

SQL> alter table order pctfree 0 pctused 20 ;

- partitioned and nonpartitioned table 모두 적용할 수 있다.

- modified attributes는 existing partition의 attributes을 modify 하기위해 사용되지 않는다. partitioned table의 default physical attributes의 변경은 add partition으로 추가되는 partition에만 적용된다.

SQL> alter index order_idx maxtrans 20 storage ( next 10M ) ;

- partitioned and nonpartitioned index 모두 적용할 수 있다.

[email protected] - 17 - 장 경상

Page 18: Oracle History #4

Oracle8 New Features http://www.ggola.com

- modified attributes는 existing partition의 attributes을 modify 하기위해 사용되지 않는다. partitioned index의 default physical attributes의 변경은 미래에 new partition이 새로 만들어 질 때에만 적용된다.

- Modified attributes가 global index에 대한 변경 이라면 alter index split partition을 통해 생성된 new partition에 적용된다. 하지만 만일 local index라면 new partition이 created implicitly by 'alter table add partition, split partition'될 때 적용된다.CF. nonpartitioned index로서 IU status인 경우 이러한 alter operations is not allowed 이다.

Unusable Index Operations

SQL> alter table order modify partition p4 unusable local indexes ;

- This command는 table partition과 matching되는 all local index partitions을 UNUSABLE로 만든다. 대량 insert후 추후 index생성 등 인덱스 관리가 DML operation이 완전히 종료된 후에 이루어져도 되는 상황에서 유용하게 사용될 수 있다.

- 다음 command를 사용하여 unusable local index partitions 을 usable로 만들 수 있다. alter index rebuild partition alter table modify partition rebuild unusable local indexes : 이 명령은 해당 partition에 연관된 all the unusable local index를 rebuild 한다.

- Index IU status를 판단하기 위해 'DBA_/ALL_/USER_IND_PARTITIONS' data dictionary 확인하라

- Table partition에 연관된 모든 unusable local index partitions을 rebuild 하기 alter table order partition p1 rebuild unusable local indexes ;

- index를 unusable 시키기 alter index order_idx unusable ; > 해당 index는 partition되어 있던 아니던 모두 가능하다. > this command는 a nonpartitioned index는 index를, partitioned index는 해당 index의 all partitions를 'INDEX UNUSABLE'로 만든다. > nonpartitioned index를 사용하기 위해선 rebuild하거나 재생성을 해야 하지만 partitioned index는 한번에 한 partition씩 rebuild 해야 한다. 물론, partitioned index도 drop후 re-creation을 해서 사용할 수 있다.

[email protected] - 18 - 장 경상

Page 19: Oracle History #4

Oracle8 New Features http://www.ggola.com

CF. 일반적으로 global partitioned indexes는 partition별 rebuild보다는 drop and re-creation이 더 효과적이다.

Index Rebuild Partition

SQL> alter index order_idx rebuild partition p1 tablespace index02 ;

- alter index command는 한번에 하나의 partition을 rebuild할 수 있다. 이런 형태는 대량의 큰 index 전체를 다시 만들지 않고 문제된 partition만 repairing하는데 매우 유용하다.CF. 이 명령은 index partition을 다른 tablespace로 옮기거나 physical attribute를 바꾸는데 사용될 수도 있고 또한 split operation같은 작업의 final step으로 사용되기도 한다.즉, 대개의 경우 index maintenance operation중 마지막 작업에 사용된다.

- Rebuild partition은 parallelism을 지원하며 우선순위는 다음과 같다. 1. 직접 지정한 parallel clause2. Default parallel attributes of the index3. Default parallel attributes of the underlying table4. Without using parallelism

SKIP_UNUSABLE_INDEXES

SQL> alter table modify partition p1 unusable local index ;SQL> alter session set skip_unusable_indexes = TRUE ;

- 위 명령은 local index를 unusable로 하였지만 그 후에 발생하는 insert,update,delete 작업을 가능케 한다.즉, insert나 update, delete시 나타날 수 있는 index 관련 errors는 override된다.CF. 일반적으로 bulk modification or load of a table partition을 위한 deferring index maintenance 에 사용된다.

- The default value for "SKIP_UNUSABLE_INDEXES" parameter는 "FALSE"이다.CF. It is not possible to skip index maintenance on UNUSABLE unique indexes.

Table Split Partition

SQL> alter table orders split partition p1 at (1997, 06, 16) into (partition p1, partition p4) ;

- 이 명령을 통해 하나의 partition을 새로운 두개의 partition으로 나눌 수 있다. split 이전의 old partition은 discard 된다. 즉, split을 통해 new partition생성시 new segment 가

[email protected] - 19 - 장 경상

Page 20: Oracle History #4

Oracle8 New Features http://www.ggola.com

만들어 지는데 new physical attributes and initial extents를 지정하여 사용할 수 있고 split하기 이전의 partition name을 그대로 지정함으로써 기존의 partition name을 살릴 수도 있다.

- Generally this command can be used when 하나의 partition이 너무 커져서 backup, recovery등 partition maintenance 작업이 to take too long 인 경우에 사용된다. 이 작업을 통해 우리는 redistribute the I/O load를 할 수도 있다.

- partition이 split되면 해당 table의 corresponding partition in each local index defined on table 또한 matching split을 수행한다. 해당 index가 INDEX UNUSABLE이어도 상관없이 진행된다.CF. 앞서 이야기 했듯이 기존 partition name을 지정해서 재사용하면 index도 마찬가지로 기존 name을 재사용하고 다만 새로 추가되는 partition만 "SYS_Pn"의 이름으로 generation된다. 물론, 재사용을 하지 않고 새로운 이름을 지정하여 split 작업을 하면 새로 생기는 index partition은 모두 "SYS_Pn"의 형식을 따른다.CF. 새로 생성되는 index partition은 parent local index의 physical attributes를 따르고 tablespace가 index 전체를 위해 define되지 않았다면, New local index partitions reside in the same tablespace as the corresponding newly created partitions of the underlying table.

- Table Split partition시 해당 partition에 data가 없었다면 split complete과 동시에 Local Index는 valid partition이 된다. If data가 있었다면 split partition은 data를 가지는 partition을 INDEX UNUSABLE로 mark할 것이다. 이 경우 하나의 partition만 data가 존재하면 하나의 partition만 IU상태가 되고 나머지 다른 partition에 data가 없다면 그 partition만 valid될 수 있다.CF. Split partition중 fail이 발생하면 new segment는 drop되고 모든 작업은 rollback 된다.

- 위 작업이 실행되면 대개의 경우 final step으로 하게되는 것이 INDEX UNUSABLE에 대한 처리이다.SQL> alter index rebuild partition ~~~~ ;

Index Split Partition

SQL> alter index order_idx split partition p1 at (1997, 06, 16) into (partition p1, partition p4) ;

- 일반적인 속성은 table split partition과 같다. 다만, underlying table partition과 관계가 없다.

[email protected] - 20 - 장 경상

Page 21: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 즉, 이 명령은 global index에만 적용되며 설사 INDEX UNUSABLE 상태의 index라도 가능하다. 물론, 이런 경우 나 data 를 가진 index split의 경우엔 모두 INDEX UNUSABLE이 되므로 Index를 VALID로 만든 후 사용해야 한다.SQL> alter index rebuild partition ~~~ ;

- global index는 아무리 split을 통해 underlying table의 partition처럼 만들어도 equipartitioned local index는 될 수 없다. 만일, 그러하길 원한다면 index drop 후 local index를 만들어야 한다.

Move Partition

SQL> alter table order move partition p1 tablespace data05 ;

- old partition's segment를 drop하고 new segment를 만든다.(move할 new tablespace지정하면 그곳으로 만일 tablespace를 지정하지 않는다면 단순한 recreation 즉, drop and create 절차만을 진행한다) partition을 다른 tablespace로 옮기기 위해 partition recreation으로 de-fragmentation 하기위해 change a physical attribute 하기 위해CF. parallel clause 사용이 가능하다.

- move할 partition이 not empty면 all affected index partitions은 INDEX UNUSABLE로 mark한다.

Exchange Partition

SQL> alter table order move exchange partition p1 ( source table) with table order_new ( target table) ( excluding indexes, including indexes) (with validation, without validation) ;

- 이 명령은 두개의 table간에 partition은 nonpartitioned table로 table은 partitioned table의 한 partition으로 exchange할 수 있도록 해준다. (by exchanging their data (and optionally index) segments)

- 대상 table은 partitioned table 이거나 cluster 이어서는 안되며 exchange하려는 두 table에 대한 alter privileges 가 있는 user만이 작업을 할 수 있다.

[email protected] - 21 - 장 경상

Page 22: Oracle History #4

Oracle8 New Features http://www.ggola.com

CF. 어떤 constraint도 enable 되어서는 안된다. (exchange partition은 triggers에 영향을 주지 않는다.)CF. 작업하려는 tables은 두 table간에 columns 수 및 size and datatype이 모두 일치해야 한다.

- this operation이 진행되면 partitioned table의 global index와 대상 table의 partitioned global indexes는 UNUSABLE로 mark된다.

- With validation을 지정하고, 대상 table에 row가 not collate properly되면 error가 return된다.Without validation이 지정되면, 대상 table의 proper collation을 확인하지 않으며, exchange partition을 analyze하고 invalid rows를 delete하여 작업결과가 logically correct되도록 한다.

- Including indexes를 사용하면 source table의 모든 local index는 target table의 regular index of the same type 이어야 하고 local index partition은 exchanged with the corresponding regular indexes.

- Excluding index는 all the local index partitions 과 target table의 all the regular indexes 을 UNUSABLE로 mark한다.

- 다음의 예를 통해 exchange partition의 작업 흐름을 알아보자. 다음은 partitioned table 'order'에서 95년 data partition과 85년 data partition을 한 partition으로 묶어서 10년 비교를 하고자 함이다.1) create table order_merge85 (..) tablespace ….. ; 옮기고 싶은 data를 가질 temporary용 table 생성2) alter table order exchange partition order_85 with table order_merge85 without validation ; exchange를 통해 table과 partition 교환 (table과 partition이 바뀌었으므로 data dictionary가 수정된다)3) alter table order drop partition order_85 ; table로 변해버린 partition을 drop (free the segment originally order_merge85)4) insert into order partition (order_95) select * from order_merge85 ; move data to target partition5) drop table order_merge85 ; partition으로 변한 table을 drop (free the segment originally order_85)6) alter table order rename partition order_95 to order_85-95 ; 필요하면 작업이 끝난 partition의 name 수정

[email protected] - 22 - 장 경상

Page 23: Oracle History #4

Oracle8 New Features http://www.ggola.com

Modify Logical Attributes

SQL> alter table order add ( new_type varchar2(2)) ;

- 일반적인 table modify와 동일하지만 partitioned table에 대해서는 몇가지 제약이 따른다.1. Table 이나 index partition에 사용된 column의 length or datatype은 바꿀 수 없다.2. Long or long raw datatype column은 add할 수 없으며 이미 존재하는 long or long raw column의 datatype도 바꿀 수 없다.3. Table partition중 하나이상이 read-only tablespace에 존재한다면 user-specified default value를 갖는 column을 add할 수 없다. varchar2(or varchar) column은 char(or character)로 변경할 수 없다. char(or character) column의 length를 증가시킬 수 없다.

- Alter command 로 Unique or primary key를 add하거나 enable하면1. 해당 column에 index가 존재하면 unique index이면 oracle은 그 index를 사용할 것이며 그 index는 global nonpartitioned, global partitioned, local prefixed, local nonprefixed index등 모든 index가 대상이 될 수 있으나 nonprefixed index의 경우엔 partitioning key를 가져야 한다. unique index가 아니면 alter statement는 error를 return할 것이다. unique index이지만 index가 IU 상태거나 index의 partition이 IU 상태이면 역시 alter statement는 error를 return할 것이다.2. Index가 존재하지 않는다면 oracle은 global nonpartitioned index를 만들 것이다.

Truncate Partition

SQL> alter table order truncate partition p3 (drop storage) ;

- truncate partition은 지정된 partition에 존재하는 모든 rows를 remove한다. (faster than using 'delete statement')

- partition이 truncate되면 corresponding local index partition도 같이 truncate된다. (IU 상태라도)Freed index space는 drop storage를 통해 deallocated 되거나 reuse storage를 통해 재사용될 수 있다.CF. the local index partitions that were marked INDEX

[email protected] - 23 - 장 경상

Page 24: Oracle History #4

Oracle8 New Features http://www.ggola.com

UNUSABLE are marked VALID, resetting the INDEX UNUSABLE indicator.

- Global index에 대해 not empty partition이 truncated되면 all global index partitions가 INDEX UNUSABLE 된다.(이런 경우 rebuild가 필요하므로 만일 rebuild를 원하지 않는다면 truncate하지 말고 manually sql delete 하라)

- FK를 가진 not empty partition을 truncate 하면 error가 return된다. 이런 경우는 FK를 먼저 disable하던지 아니면 manually sql delete한 후 truncate해야 한다.CF. truncate partition does not fire the table's DELETE triggers.

Index Parallel

SQL> alter index order_idx parallel (degree 5 instances 2) ;

- this command로 partitioned index의 parallel attributes를 정할 수 있다. CF. index scan시 one slave가 one partition에 작업을 할 수 있다. 위의 예는 5개의 index partitions에 partition당 one slave가 할당될 수 있다.

- parallel create index에서 default parallelism을 위해 사용된다.

Privileges for Partitioned Tables and Indexes

- nonpartitioned tables and indexes 에 대한 privileges는 partitioned tables and indexes에도 동일한 privilege를 갖는다.CF. 단, table owner가 아닌 user가 ‘alter table drop partition, alter table truncate partition’ operation을 하려면 ‘alter’ privilege와 함께 'Drop any table' privilege가 있어야 한다.

- 다음의 명령들은 privilege외에 a space quota in tablespace를 요구한다.Alter index modify/rebuild/ split partitionAlter table add/modify/move/split partition

an additional portion for partition features

Data Dictionary Lists (USER/ALL/DBA prefixed dictionary)

- _PART_TABLES, INDEXES, KEY_COLUMNS

- _TAB/IND_PARTITIONS

[email protected] - 24 - 장 경상

Page 25: Oracle History #4

Oracle8 New Features http://www.ggola.com

- _PART/TAB/_COL_STATISTICS

- _PART/TAB/_HISTOGRAMS

- _OBJECTS, _TABLES, _TAB_COLUMNS

New Columns of the PLAN Table

PARTITION_START, PARTITION_STOP

- PARTITION_START, PARTITION_STOP : how oracle computes the partitions to be accessed and provide the range of accessible partitions

- Values : number(n), key, row location, invalid

- NUMBER(n) : indicates that the start partition has been identified by the SQL compiler. Its partition number is given by n

- KEY : indicates that the start partition will be identified at execution time from partitioning key values.

- ROW LOCATION : indicates that the start partition(same as the stop partition) will be computed at execution time from the location of each record being retrieved. The record location is obtained by a user or from a global index.

- INVALID : indicates that the range of accessed partitions is empty

PARTITION_ID

- this column identifies the step that has computed a pair of values PARTIONT_START and PARTITION_STOP columns.

OPTIONS column for PARTITION Step(newly added execution step)

- values : concatenated, single, empty

- CONCATENATED : 2개 이상의 partitions에서 returned result sets를 concatenation

- SINGLE : accessed partition이 execution time에 a single partition 이다.

- EMPTY : accessed partition이 empty

CF. table access and index step : can contain the values 'by user rowid, by index rowid, by global index rowid, by local index rowid'

[email protected] - 25 - 장 경상

Page 26: Oracle History #4

Oracle8 New Features http://www.ggola.com

SQL*Loader

- conventional path : partition table에 대한 load도 가능하다.1. SQL insert statement를 사용한다.2. Same table에 대하여 concurrently하게 can run multi load and can load different partitions 3. Must specify the table and partition name is the load control file4. 지정된 partition에 속하지 않는 rows는 'BADFILE'로 쓰여진다.

- Direct path sequential loads : 1. Index are build automatically.2. Must specify the table and the partition name and set DIRECT=TRUE.3. If you are loading for the whole table, you cannot run any other loads on the same table concurrently4. If there are no global indexes, you can run sequential direct path loads on different partitions of the same table concurrently

- Direct path parallel loads1. Must specify the table name and the partition name and set DIRECT=TRUE and PARALLEL=TRUE2. Local index는 IU 상태가 되므로 loading이 끝나면 rebuild해야 한다. (rebuild the partitions explicitly)3. Global index가 있어서는 안된다. 꼭 필요하다면 global index drop and direct path parallel loading and re-create the index 해야 한다.4. Can run parallel direct path loads on different partitions of the same table concurrently

Export / Import

- Export : table mode에서만 partition export가 가능하다. CF. 다음과 같은 형식을 사용한다. table_name:partition_name

- Import : partitioned table에 대한 import시 values less than in the highest partition에 해당되지않는 그 이상의 값을 갖는 rows는 모두 reject한다.CF. 다음과 같은 형식을 사용한다. table_name:partition_nameCF. SKIP_UNUSABLE_INDEXES를 설정하여 UNUSUABLE maintenance를 skip할 수 있다.

Analyze

- partitions는 개별적으로 모든 analyze를 할 수 있다.CF. 물론 whole table and index애 대한 analyze는 자동으로 해당 partition전체에 적용된다.

[email protected] - 26 - 장 경상

Page 27: Oracle History #4

Oracle8 New Features http://www.ggola.com

- analyze generates 'combined' table, index and column statistics for a partitioned table or index by merging the statistics from the partitions. 하지만 analyze는 combined histogram을 생성하지는 않는다.

- optimizer 가 아직 analyzed되지 않은 partition을 발견한다면 그때는 each partition에 table/index defaults를 사용한다.

[email protected] - 27 - 장 경상

Page 28: Oracle History #4

Oracle8 New Features http://www.ggola.com

4. Parallelizing Insert, Update and Delete Operations

Parallel Operation

대략 megabytes or gigabytes급 table or index에 대하여 적어도 1%이상의 변경을 일으키는 Large DML operations에 대하여 speed up을 기대할 만 하다.

일반적으로 DSS or DW 같은 large objects access시 performance and scalability가 중요한 시스템에서 주로 사용된다. (some OLTP operation에서도 효과를 기대할 수 있다)

parallel DML compliments the parallel query architecture by providing parallel support for Insert, Update, Delete operations.

대개의 경우 parallelism은 partitioned tables and indexes에 대하여 적용이 된다. 단, 예외적으로 'Insert .. as select … ' on a nonpartitioned table에 대해선 허용한다.

Benefits of Parallel

parallel DML의 목적은 performance의 많은 향상이나 반드시 hardware support가 필요하다.

The performance of parallelism is not only based on number of processes spawned. The number of CPU's, the number of disk drives on which the data is located, and some other factors all have an impact

Automatic parallelization

- 여러 session에서 parallel update를 수행할 필요가 없이 자동으로 parallel DML operations을 사용할 수 있다.(조건별로 나누어 여러 session에서 동일 DML을 할 필요가 없다)

- 여러 session에서 처리할 필요가 없으므로 level of work를 나누기 위한 key value or ROWID ranges를 알아야 할 필요가 없다. (따라서 transaction control에 대한 부담이 없이 완전하게 하나의 transaction으로 처리가 되어진다)

[email protected] - 28 - 장 경상

Page 29: Oracle History #4

Oracle8 New Features http://www.ggola.com

Affinity

- Oracle uses partition-to-device mapping. A process can be allocated to specific device for a given partition.

- Users는 DML 실행 시 node/device/file/table/partition affinity를 알아야 할 필요가 없다.

Oracle Parallel Server

- OPS환경에서 parallel operations을 수행할 때 manual parallelism을 사용기 위해선 instance별 degree of affinity에 따라 결정해야 한다.

- Parallel DML은 implicitly managed되고 slave processes는 allocated to a given partition on an individual devices

Supported Parallel Operations

Parallel DML

- Parallel Query : Oracle7 과 same architecture

- Parallel Insert .. Select direct load on partitioned tables or nonpartitioned tables

- Parallel Delete on partitioned tables, parallelize by partition

- Parallel Update on partitioned tables, parallelize by partition

Types of Parallelism

- 하나의 master process가 slave processes를 coordinate한다.

- 세가지 방식의 parallel operations이 있다.1. Parallelize by rowid ranges (for parallel query only)2. Parallelize by slave processes (for inserts into unpartitioned tables only)3. Parallelize by partitions (for partitioned tables only)

Parallelize by rowid

- parallel query를 위해 사용되며 partitioned and nonpartitioned tables에 대하여 구분이 없이 모두 사용할 수 있다.

[email protected] - 29 - 장 경상

Page 30: Oracle History #4

Oracle8 New Features http://www.ggola.com

- provide parallelism within a partition, 1개의 process는 1개의 partition만 담당한다. (동시에 여러 process가 1개의 partition을 select할 수 있다)

Parallelize by slave processes

- insert into table select from table operation for nonpartitioned tables에 대해서만 사용이 가능하다. (parallel degree는 insert하려는 대상 table에 준다)

- Multiple slaves can insert after the high water mark(HWMK) of the table.

Parallelize by partitions

- partitioned table만을 대상으로 하는 INSERT .. SELECT, UPDATE, DELETE Command만 적용된다.

- cannot provide parallelism within a partition .

- resource의 sharing and use를 위해 1개의 process는 1개 이상의 partition에 assigned될 수 있다. 그러나 1개의 partition에 1개 이상의 process가 할당될 수는 없다.

- Parallel Insert for partitioned table은 temporary segments를 사용하여 insert를 진행하고 생성된 segment를 대상 table의 HWMK 위에 add한다.

- segment가 1개씩 add될 때 HWMK가 이동하고 newly inserted rows에 대하여 ROWIDS가 assigned 된다.CF. 이후의 원칙은 Direct Path mode in SQL*Loader와 같다.

Enabling Parallel DML

- default Parallel DML mode는 FALSE로 되어있으므로 처음 session을 맺어서는 parallel DML을 사용할 수 없다. 반드시 다음과 같이 alter session command를 사용하여 enable후 사용을 해야 한다. 단, parallel query는 이와 무관하게 원래부터 사용할 수 있으므로 유의하라.SQL> ALTER SESSION ENABLE PARALLEL DML ;(반대는 DISABLE)

Parallel DML Mode

- Initial parameter에 설정되어 있지않고, Alter session command를 사용할 때는 사전에 commit or rollback을 통해 current transaction이 종료되어 있어야 한다. 그렇지 않으면 external error를 return할 것이다.

[email protected] - 30 - 장 경상

Page 31: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Each successful parallel DML operation후에는 다른 SQL command를 수행하기 이전에 반드시 commit or rollback이 수행되어야 한다. 그렇지 않으면 commit or rollback을 수행하라는 error (12830)가 return될 것이다.

- 한 transaction에서 first DML이 serially 수행되거나, Lock Table or Select for update 문장을 사용한 경우 그 이후에 사용되는 모든 parallel은 무시된다. 즉, 모두 serially 수행된다. (단순 select는 상관없다)CF. 이것은 Oracle 8.0.3까지의 제약 사항이다.

- PL/SQL procedure or block이 Parallel DML enabled session에서 수행되면 each statement in the procedure or block에 모두 같은 rule이 적용된다.

Using Parallel

Parallel Clause

SQL> create table table_name (column type ….) parallel (degree 4) ;

- create or alter table command로 parallel clause을 사용하여 default degree of parallelism을 설정할 수 있다.

Parallel Hints

SQL> Update, Delete /*+ parallel (table, n) */ ……SQL> Insert /*+ append parallel (table, n) */ into…. /*+ noappend parallel (table, n)*/

- explicit hints를 지정하면 즉, hint를 사용하여 parallel DML을 사용하면 parallel clause을 이용한 default setting은 override된다.

- Insert hint에 사용된 parallel은 select operation에는 적용되지 않으며 설사 insert와 동일 table에 select라도 적용되지 않는다. parallel hint가 없다면 parallel clause을 사용할 것이다.CF. Parallel DML enable상태에서 append는 append insert parallel로 진행될 것이고 disable상태면 append insert serial로 진행될 것이다.CF. noappend hint는 conventional insert를 진행한다.

Determining the degree of parallelism

- Parallel DML adds some new limits to the degree of parallelism to prevent deadlock situations.

[email protected] - 31 - 장 경상

Page 32: Oracle History #4

Oracle8 New Features http://www.ggola.com

- The minimum number of transaction free lists for a partitioned global index is the minimum number across all index partitions. This is a requirement in order to prevent self-deadlock.

- If a certain minimum fraction of the desired slave processes is not available(specified by PARALLEL_MIN_PERCENT), a user error is produced. You can retry the query with less parallelism.

Parallel select

- parallel hint or table level의 parallelism에 따라 parallel select가 수행된다.

- One parallel directive for degree of parallelism is chosen for the entire statement, following these precedence rules :1. Select hint directive2. Select clause directive3. Maximum select directive (join처럼 2 table 이상을 scan시 1, 2중 제일 큰 값을 사용한다)

Parallel Insert .. Select

- parallelizing에 영향을 주는 4대 요소1. select parallel hint (at the statement level)2. parallel clause (definition of the tables)3. insert parallel hint (at the statement level)4. parallel clause (definition of the table)CF. Oracle chooses one overall Parallel directive for the entire statement.

- 선택 순위1. Insert hint directive2. Insert clause directive3. Maximum select directive

EX) insert /*+ parallel (emp, 3) / into emp select /*+ parallel (emp_src, 6) */ from emp_src ;

위의 예에서 선택되는 degree는 ? 3

Parallel update and delete

- Parallel hint is applied to both the implicit query portion of the statement and to the DML portion.

- If the statement contains subqueries or updatable views, they may have their parallel hints or clauses.

- 만일 update중 발생하는 table scan이 serial 발생하더라도 즉, where clause 등에서 index scan이 serial로

[email protected] - 32 - 장 경상

Page 33: Oracle History #4

Oracle8 New Features http://www.ggola.com

발생하더라도 update 자체의 parallel operation은 수행될 것이다.

- 선택 순위1. Update/Delete hints2. Update/Delete clause

Parallel DML and the Data Dictionary

- Parallel DML이 수행되면 V$PQ_SESSTAT, V$SESSION, V$PQ_SYSSTAT을 조합하여 적절한 정보를 찾을 수 있다.

- Parallel DML이 enable인가? PDML_ENABLED column from V$SESSION

- Parallel DML이 수행되고 있는가?Select * From V$PQ_SESSTAT; current session parallel 정보 Select * From V$PQ_SYSSTAT; initialized parallel DML 수

Logging / Nologging

SQL> alter table table_name LOGGING ;

- NOLOGGING Attribute는 statement level이 아니라 alter or create command 즉, object level에서 수행되어야 한다.

- Tablespace level에서도 설정이 가능하며 이렇게 NOLOGGING을 설정하는 경우 all subsequent tables, indexes and partitions등 모두 do not generate redo logs entries.그러나 lower level에서 table, index등 object level에서의 설정이 우선한다.

Parallel DML and Rollback Segments

- Parallel DML이 수행되면 개별적인 slave process별 transaction이 발생하므로 동시에 different rollback segments를 할당 받는다.

- 따라서 the coordinator는 내부적으로 slave process별 two-phase commit방식을 취하게 된다. 당연히 rollback segment를 지정하는 set transaction use rollback segment command는 유효하지 않다.

- Parallel DML을 수행하는 a query slave는 long-running transactions수가 가장 적은 것을 우선으로 하여 rollback segment를 할당 받는데 만일 in each rollback segment 동수의 long-running transaction이 할당되어 있을 때는 regular DML수가 가장적은 것을 할당한다.

[email protected] - 33 - 장 경상

Page 34: Oracle History #4

Oracle8 New Features http://www.ggola.com

CF. 가급적 equally sized rollback segment를 가질 필요가 있다. 앞서 언급했듯이 어떤 slave가 어떤 rollback segment에 할당될 지는 알 수가 없기 때문이다.

General Restrictions

- 아래와 같이 General Restrictions에 위반되는 parallel DML이 수행되면 error를 return하지 않고 serially 수행될 것이다.

- 한 transaction에서는 단 1회의 parallel DML만 허용되며 사전에 다른 serial DML이 수행되면 안된다.(이런 제약사항은 Oracle V8.0.3이하 버전에서만 유효하고 이후의 버전에서는 이미 수정되어 그런 제약은 없어졌다.)

- 이후 버전에서도 parallel DML이 발생한 후 commit or rollback 없이 동일 table에 대하여 select 나 또 다른 parallel DML은 허용되지 않는다. 하지만, 다른 table에 대한 작업(parallel DML을 포함하여)은 여전히 유효하다.또한, LOB type이나 user defined object type을 포함하는 table에 대한 parallel DML은 허용되지 않고 무조건 serially 처리된다.

- 한 transaction에서 Lock table or Select for update를 사용하면 이후의 작업은 모두 serially로 진행된다.

- no parallel insert on global index (to avoid self-deadlock)no parallel update on global unique indexno parallel DML operation on tables contains LOBs or object typesno parallel DML operations for bitmap indexesno parallel DML operations on clustered tables

- Parallel DML이 정상적으로 수행되어도 triggers는 enable되지 않는다. 즉, trigger를 사용하는 replication을 사용할 수 없다.

Transaction and Process Recovery for Parallel DML

- Transaction Recovery(for system and instance recovery)1. SMON에 의해서 수행된다. Parallel DML이 있는 transaction의 recovery는 serially 처리될 것이며 recovery가 완료될 때까지 all resources locked된다. 그러므로 forward transaction에서 high degree를 사용한 경우 original(forward) transaction의 rollback보다 recovery가 take much longer될 수 있다.2. 따라서 이렇게 instance가 비정상 종료로 인해 recovery할 때는 to speed up the recovery process, rerun 앞서 비정상

[email protected] - 34 - 장 경상

Page 35: Oracle History #4

Oracle8 New Features http://www.ggola.com

종료되었던 the parallel DML statement and return commit or rollback하라. a user-issued rollback does not require recovery.

- Process Recovery1. Single slave가 fail되면 PMON이 그 작업을 rollback할 것이고 나머지 slave는 그들 자신의 작업을 rollback할 것이다.2. Multiple slave가 fail되면 PMON이 serially하게 rollback을 대행할 것이다.3. Coordinator process가 fail되면 PMON이 coordinator를 recover할 것이고 all slave processes는 parallel하게 자신들의 작업을 rollback할 것이다.4. 따라서 Process recovery time은 the forward work와 비슷하거나 더 오래 걸릴 것이다.

[email protected] - 35 - 장 경상

Page 36: Oracle History #4

Oracle8 New Features http://www.ggola.com

5. Identifying New ROWID Structure

Addressing formats

Oracle8에서 새롭게 강화된 기능들은 결국 addressing format에 대한 변경을 요구하게 되었고 따라서 New ROWID(Extended ROWID)가 탄생하게 되었다.

대표적으로 Larger Database, Many more datafiles, Many more tablespaces, Efficient access to partitioned objects 이러한 것들을 예로 들 수 있다.

New ROWID(Extended ROWID)

Why is a new ROWID Format Needed ?

- 기존의 ROWID는 file, block, row number로 구성되어 있었으나 이제 Oracle8에서 datafile number는 보다 더 많은 의미를 표현할 필요가 있게 되었다.

- Because Oracle8은 partitioned table이 multiple segments를 가질 수 있고 각 segment는 분리된 tablespace에 위치할 수 있다라는 것을 지원하므로 segment를 표현해야 하는 ROWID에는 부가적인 정보가 필요할 수 있게 되었다.

- Oracle uses ROWID as a unique identifier for a row in B-tree indexes and in internal algorithms.

- DBA_DATA_FILES의 FILE_ID는 database에서 unique하고, DBA_DATA_FILES의 RELATIVE_FNO는 tablespace에서 unique하다. (because of PARTITON)

New ROWID Format

SQL> select rowid from table ;ROWID--------------------------------------AAABeVAAEAAAATRAAA…………….

- 64 encoding 방식으로 알파벳 대소문자 + 숫자 + '+', '-' 기호로 표현된다. (A~Z, a~z, 0~9, +, -)

AAABeV (6자리) AAE (3자리) AAAATR (6자리) AAA (3자리)

Data object # Relative file # Block # Slot #

[email protected] - 36 - 장 경상

Page 37: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 여러 datafile은 각각 different tablespace의 구성요소 이므로 the same relative file number를 가질 수 있지만, table 의 row information을 구할 때는 이미 tablespace를 알고 있는 상태이므로 tablespace당 relative file number의 unique속성을 이용해 data를 access를 할 수 있다.

- initially object number는 DBA_OBJECTS의 OBJECT_ID로 볼 수 있고 data object number인 DBA_OBJECTS의 DATA_OBJECT_ID와 동일하다. 하지만 version changes가 일어날 때마다 data object number는 증가한다. (table truncate나 move partition이 발생하면 version이 바뀐다)

- Oracle8 ROWID 즉, extended ROWID는 내부적으로는 <data object number>, <data block address>, <row number> 이 3가지를 위해 10bytes를 사용하는 format으로 저장되어 있고 the address has to be absolute일 때마다 extended ROWID를 사용한다.CF. 예를 들면 global index on partitioned tables의 경우 the correct partition이 필요하므로 일반 index보다 많은 entry 정보를 저장하기위해 보다 많은 space를 할당해야 한다.CF. 그 밖에 : Server Algorithms, Storage Format in columns defined as ROWID등 에서 필요하다.

Restricted ROWID (Old style ROWID)

- Oracle8은 old style인 Oracle7 style의 ROWID를 support한다.

- 이런 형태의 구 rowid는 다음의 경우에 유용하게 사용된다.1. Nonpartitioned table의 index entries2. Partitioned table내의 local index entries3. Row piece chain pointers

00000000. (8+1) 0000. (4+1) 0000 (4자리)

Old Style : Block Number Row Number File Number

- extended ROWID value가 있는 ROWID column을 가진 table에 대하여 Oracle8에서 Oracle7로의 export는 될 수 없지만 ROWID column을 가진 table의 Oracle7에서 Oracle8로의 export는 될 수 있다. CF. 물론, Oracle8로 export된 table의 ROWID values는 update되어야 할 것이다.

- Querying Oracle7 Rowid from Oracle8 : Oracle7 rowid를 return하고 where clause에서 사용할 수 있다.

- Querying Oracle8 Rowid from Oracle7 : Oracle8 rowid를 return될 수 있고(DBMS_ROWID function도 사용할 수 있다)

[email protected] - 37 - 장 경상

Page 38: Oracle History #4

Oracle8 New Features http://www.ggola.com

where clause에서도 사용할 수 있지만 rowid column으로 저장될 수는 없다.

Migration

Issues

- The application이 ROWID를 access하거나, table이 ROWID type의 column을 가지고 있는 경우에 migration 문제가 제기될 수 있다. 이 경우 ROWID를 다시 만들거나 ROWID interpret을 통해 해결해야 한다.CF. 그 외의 다른 application에는 영향을 주지 않는다.

- ROWID column을 가진 Oracle7 tables을 migration하기 위해서는 export/import 후 repopulate ROWID를 하거나 migration utility를 사용하여 작업한 후 DBMS_ROWID package를 이용하여 ROWID column value를 convert해야 한다.

DBMS_ROWID

- ROWID에 적용될 ROWID_ functions을 제공하는 package

ROWID_ CREATE, INFO, OBJECT, RELATIVE_FNO, BLCOK_NUMBER, ROW_NUMBER, TO_ABSOLUTE_FNO, TO_EXTENDED, TO_RESTRICTED, VERIFY

- DBMS_ROWID.ROWID_TO_EXTENDEDrestricted ROWID를 extended ROWID로 translate

ROWID_TO_EXTEDED Argumentold_rowid in rowid, ROWID column nameschema_name in varchar2, referenced schemaobject_name varchar2, referenced objectconversion_type number(38) conversion : 0 internal, 1 externalRETURN ROWID CF. 0은 rowed column으로 저장, 1은 character로 return

SQL> select * from rid where r_id = '??' ; SCOTT user의 restricted ROWIDSQL> update rid set row_id = dbms_rowid.rowid_to_extended(row_id, 'SCOTT', 'TABLE', 0) ;SQL> select * from rid where r_id = '??' ; extended ROWID

[email protected] - 38 - 장 경상

Page 39: Oracle History #4

Oracle8 New Features http://www.ggola.com

- DBMS_ROWID.ROWID_TO_RESTRICTEDOracle7 version에서 Oracle8 data를 rowid로 access

ROWID_TO_RESTRICTED Argumentnew_rowid in rowid,conversion_type in number(38)RETURN ROWID

- DBMS_ROWID.ROWID_VERIFYROWID_TO_EXTENDED 를 사용하여 restricted ROWID로 conversion이 가능한가를 검사.

ROWID_VERIFY Argumentold_rowid in rowid,schema_name in varchar2,object_name in varchar2,conversion_type in number(38)RETURN NUMBER conversion : 0 ok, 1 not ok

- DBMS_ROWID.Information Functionsrowid를 argument로 extended ROWID information 가져오기

ROWID_ TYPE, OBJECT, RELATIVE_FNO, BLOCK_NUMBER, ROW_NUMBER

CF. ROWID_TO_ABSOLUTE_FNO function은 absolute file number를 가져오기 위해 ROWID외에 SCHEMA_NAME, OBJECT_NAME이 필요하다.

- DBMS_ROWID.Procedures : ROWID_ INFO, CREATE

- ROWID_INFO Procedure : ROWID를 가지고 extended ROWID의 address information을 알아낼 수 있다. 그러나 이는 function이 아니므로 SQL 문장 내에서 사용할 수 없다.

ROWID_INFO Argumentrowid_in in rowid,rowid_type out number, return 1 extended, 0 restrictedobject_number out number,relative_fno out number,block_number out number,row_number out number

CF. ROWID_CREATE procedure는 only useful for testing

[email protected] - 39 - 장 경상

Page 40: Oracle History #4

Oracle8 New Features http://www.ggola.com

6. Defining Object Relational Features

What is an object of Oracle ?

Attribute : built-in types or other object types(the real world entity 구조를 modeling)

Methods : database내에 저장된 형태로 존재하는 functions or procedures(PL/SQL), C와 같은 external language등

Objected-Relational DB of Oracle ?

User-defined datatype을 지원한다. (1개의 Attribute에 여러 meaning(columns)을 나타낼 수 있다)

Multimedia and large data objects를 지원한다

SQL Standard를 벗어나지 않도록 하여 기존 SQL에 큰 변화를 주지 않도록 한다.

기존 RDB의 강점을 그대로 살려 SQL, OLTP처리를 더 강력히 하고 VLDB를 지원한다.

Benefits of Object Technology

1. Easy maintenance of applications (maintenance 비용 절감)

2. Faster product development (company 경쟁력 향상)

3. Higher quality of code at a lower cost

4. Reusability of code (공통 module의 재사용으로 인한 시간과 비용의 절감)

Object Technology Components

1. object type : special한 data요구를 지원하기 위해 custom datatypes을 생성할 수 있다.

2. object extensions : object를 다루기 위한 SQL and PL/SQL implementation

[email protected] - 40 - 장 경상

Page 41: Oracle History #4

Oracle8 New Features http://www.ggola.com

3. object views : relation data를 object-oriented framework로 확장한다.

4. programmatic interfaces : support objects through Pro*C, Pro*COLBOL, PL/SQL, and OCI with new libraries, object integration, and the Object Type Translator.

Objects Type

Defining object types

- an object type is a composite datatype defined by the user.

- An object-type specification defines all attributes and methods that implement object-type behavior

Attribute Types

- type : user-defined type, built-in type

- built-in type : scalar, collection, relationship

- scalar : char, nchar, nvarchar2, varchar2, long, raw, long raw, number, date, blob, clob, nclob, bfile nchar, nvarchar2 : character set에 맞는 문자를 1자리로 blob : binary large object clob : character large object bfile : binary large file object nclob : fixed-width multibyte character large object

- collection : varry(varying array), table(nested table)

- relationship : ref(reference : pointer of data address)

Using an object type

- object type 인 column으로 relational table 만들기

- table을 attribute로서 object type으로 만들기

- object type을 기반으로 하는 object table 만들기

- object view 만들기

- PL/SQL내에 object type의 local variable 사용하기

[email protected] - 41 - 장 경상

Attribute

s

Methods

Page 42: Oracle History #4

Oracle8 New Features http://www.ggola.com

Object

Creating object type

- Object type or built-in datatypes을 모두 이용하여 만들 수 있다. 단, long 이나 long raw, rowid와 %type을 사용할 수는 없다.

- definition에서는 반드시 unique한 attribute name을 사용해야 하지만, definition이 다른 곳에서는 same attribute name을 사용할 수 있다. (한 schema에서도 가능하다) attribute name은 30 characters length가 maximum이다.

- Create a relational table with an object type

- create an object table

위의 경우 object는 relational table의 row로 저장되고 identifier도 없고 따라서 reference 되지도 않는다.

[email protected] - 42 - 장 경상

SQL> create type mem_type as object(name varchar2(10), phone varchar2(10)) ;/

SQL> create table member(mem_no varchar2(5), mem_tp mem_type) ;

SQL> insert into member values(12345, mem_type(‘JANG’, ‘6426’)) ;

SQL> select m.mem_tp.name from member m ;

JANG

SQL> create type mem_type as object(name varchar2(10), phone varchar2(10)) ;/

SQL> create table member of mem_type ;

반드시 필요

Page 43: Oracle History #4

Oracle8 New Features http://www.ggola.com

Defining relationships between objects

- allows you to declare a type that refers to objects of the same or another type : this relationship is called a reference (REF)

Object Reference

- The REF operator builds a reference to the identity and location of the referenced object. REF는 system generated value이고 pointer를 이용하여 ease of navigation and implicit joins을 가능케 한다. 물론, 이 REF는 object table에 object만을 reference한다.

- Typically, a REF is comprised of the target OID, an object table identifier, and a database identifier.

- REF 다음의 syntax를 통해 column로 저장될 수 있다.column_name REF object_type_table SCOPE IS table_name

[email protected] - 43 - 장 경상

SQL> create type emp_type as object(emp_no integer, mem_loc REF mem_type) ; /

SQL> create table emp of emp_type(SCOPE FOR (mem_loc) IS member) ;

SQL> insert into emp select 100, REF(m) from member mwhere m.phone = 1234 ;

SQL> select mem_loc from emp ;

00002030B9490B……….

Page 44: Oracle History #4

Oracle8 New Features http://www.ggola.com

Member

Member methods

- object type은 1개 이상의 member methods를 가질 수 있다.

- Member methods는 input and output parameters를 가지며 written by user로 만들어진 일종의 subprogram으로 functions or procedures로 만들어질 수 있고 반드시 return value를 가져야 한다.

Object types are complex and the database cannot automatically define the comparison semantics.

you define how an object is to be ordered and compared by specifying a MAP or an ORDER function.

CF. MAP function must return a scalar datatype, 만일 object가 쉽게 scalar datatype을 return할 수가 없으면 ORDER function을 사용하라.

[email protected] - 44 - 장 경상

SQL> create type addr_type as object(street varchar2(30), city varchar2(30), state char(2), zip varchar2(10)) ;/

SQL> create or replace type person_type as object (last_name varchar2(30), first_name varchar2(30),phone varchar2(12), birthdate date, addr addr_type member function age return number,pragma restrict_references(age, RNPS,WINPS,WINDS)) ;

SQL> create or replace type body person_type as member function age return numberis begin return trunc(months_between(sysdate, birthdate)/12); end ;end ;/

SQL> create table f_emp (empno number, emp person_type) ;

SQL> insert into f_emp values(1, person_type(‘JANG’, ‘Kyung Sang’, ’82-2-6426-6426’, ’4-JUL-1970’, NULL)) ;

SQL> select empno,e.emp.last_name, e.emp.first_name, e.emp.age()from f_emp e ;

1 JANG Kyung Sang 30

Type body 에 member

function specification 기술

반드시 Alias 사용

Page 45: Oracle History #4

Oracle8 New Features http://www.ggola.com

Collection

new datatype in Oracle8 : VARRAY, (nested)TABLE

scalar values or object type instances를 가지며 ordered and unordered one-to-many relationships을 제공한다.

Collection은 a grouping of similar items. Array type은 ANSI SQL Standard의 확장이지만, nested table은 ANSI표준이 아니다.

CF. collection datatype을 사용하는 Parallel query, Parallel DML, replication, and distributed functionalities은 Oracle8에서 지원하지 않는다.

Defining a VARRAY

- array는 ordered set of elements이다. VARRAY는 count 와 limit의 속성을 갖는다. count : current number of elements limit : maximum number of elements the varray can contain(limit은 user defined)

- Values are stored in-line unless they are greater than 4KB, then they are stored out-of-line.

- An elements는 unique position in the array을 가진다. Position은 integer로 지칭되고 1부터 시작한다.

CF. default values and constraints는 지정될 수 없다.CF. elements of an array는 개별적인 SQL로 접근할 수 없고 PL/SQL or 3GLs을 사용해야 한다.

[email protected] - 45 - 장 경상

SQL> create type phone_type as object(name varchar2(10), phone_no varchar2(12));/

SQL> create type phone_list_type as varry(5) of phone_type;/

SQL> create type custom_type as object (custid number, contact varchar2(50),phone_nos phone_list_type) ;/

SQL> create table customer of custom_type ;

Page 46: Oracle History #4

Oracle8 New Features http://www.ggola.com

Defining a Nested Table

- multiple columns를 가진 table type의 datatype을 table내에 지원할 수 있다. 즉, master-detail relationships에 유용하다.

- 본 table외에 별도의 segment를 할당 받아 사용된다.

- Characteristics of table type1. natural mapping for one-to-many relationships2. sets of scalars, object_types, and REFs as nested sets3. set-at-a-time fetch and binds4. support for queries and indexes

Array and nested table 비교

- arrays는 별도의 segments를 가지지 않는다.

ARRAYS NESTED TABLES

Ordered collection Multiset behavior

Stored in-line (4KB까지는) Stored out-of-line

No support for indexes Supports indexes

Upper limit on number of elements (in SQL)

No upper bound on size

No select of elements Can select nested rows

[email protected] - 46 - 장 경상

SQL> create type phone_type as object(name varchar2(10), phone_no varchar2(12));/

SQL> create type phone_list_type as table of phone_type;/

SQL> create table customer of (custid number, contact varchar2(50),phone_nos phone_list_type)Nested Table phone_nos store as phone_nos_nest ;

Page 47: Oracle History #4

Oracle8 New Features http://www.ggola.com

Object View

Why use Object Views

- access to relational data for object-oriented applications

- flexibility in supporting multiple object-based schemas for relational and object data

- coexistence of current applications with new applications that leverage the object-oriented framework(new application과 변경하지 않은 legacy applications or procedures를 함께 사용할 수 있다)

- relational table에 object식 coding을 할 수 있다.(ease application migration)

Creating Object Views

- Using object views, you can build virtual objects from relational data.

- create table create object type create object view create instead of trigger (updatable views with instead of triggers)

[email protected] - 47 - 장 경상

SQL> create table member (memid number(8) primary key, fname varchar2(30),lname varchar2(30), mem_desc varchar2(50)) ;

SQL> create table bestmem (memid number(8) references member,best_point number(3), salary number(18,3),company_nm varchar2(50)) ;

SQL> create type mem_type as object (memid number(8) primary key, fname varchar2(30),lname varchar2(30), mem_desc varchar2(50)) ;/

SQL> create or replace view best_mem_vw asselect mem_type (memid, fname, lname, mem_desc) employee, b.best_point, b.salary, b.company_nmfrom bestmem b, member mwhere b.memid = m.memid ;

RDB Table Creation

User-Defined Type

Object View Creation

Page 48: Oracle History #4

Oracle8 New Features http://www.ggola.com

[email protected] - 48 - 장 경상

SQL> create or replace trigger emp_trg instead of insert on best_mem_view for each rowbegin insert into member values (:new.employee.memid, :new.employee.fname, :new.employee.lname, :new.employee.mem_desc) ; insert into bestmem values (:new.employee.memid, :new.best_point, :new.salary, :new.company_nm) ; end ;

SQL> insert into best_mem_view values (mem_type ( 1, ‘Jang’, ‘Ksang’, ‘DBA’),80, 300, ‘Cyberlogitec’) ;

SQL> insert into best_mem_view values (mem_type ( 2, ‘Lee’, ‘BRE’, ‘DBA’),70, 200, ‘Cyberlogitec’) ;

Instead OF Trigger

Insert to Object View

Page 49: Oracle History #4

Oracle8 New Features http://www.ggola.com

7. Managing Large Objects

LOB Datatypes

LOBs

- BLOB : a binary file

- CLOB : a character large object

- NCLOB : a fixed-width multibyte character large object

- BFILE : a binary file stored outside the database

CF. LOB types간의 data conversion은 directly transferable할 수 없다.

LONG 과 LOB

- LONG & LOB CONTRASTING

LONG, LONG RAW LOB

Table당 1개의 column만 Table당 1개 이상의 columns

2 Gigabytes 까지 4 Gigabytes 까지

Select로 data return Select로 locator return

Data stored in-line Data stored in or out–of-line

Object type 지원하지 않음 Object type 지원

Sequential access to column value

Random access to column value

- LOBs store a locator in the table and the data elsewhere, unless it is less than 4000 bytes.

- LOBs allow data to be stored in a separate segment and tablespace, or in a host file.

- LOBs support object type attributes(except NCLOBs). object type 사용으로 dynamic한 data찾기가 가능해 졌다.LONGs do not. serial하게 data를 찾는다.

[email protected] - 49 - 장 경상

Internal LOBs : stored in the database

External LOBs :stored outside the database

Page 50: Oracle History #4

Oracle8 New Features http://www.ggola.com

Using a LOB

- LOB value는 저장된 real data이고 LOB locator는 LOB value location의 indicator이다.

- LOB을 사용하는 프로그램에서는 LOBs data를 access하고 manipulate하기 위해 pointer or LOB locator를 필요로 한다.

Internal LOBs

BLOB, CLOB, NCLOB

- An attribute of a user-defined type

- A column

- A SQL bind variable

- A program host variable

- A PL/SQL variable, parameter, or result

Advantage

- concurrency mechanisms

- redo logging

- recovery mechanisms

BLOB : interpreted by the Oracle8 Server as a bitstream (like LONG RAW)

CLOB : interpreted as a single-byte character stream

NCLOB : interpreted as a fixed-width, multiple-byte character stream, based on the byte-length of the database national character set ( Oracle 8.0.3 이하에서는 attribute로 사용할 수 없다)

[email protected] - 50 - 장 경상

DECLARE vl_job BLOB ;BEGIN

Select data_desc into vl_job from data_jobs where ……… ;END ;

Page 51: Oracle History #4

Oracle8 New Features http://www.ggola.com

Definition for LOB

- LOB은 object type을 이용하거나 혹은 직접 기술해서 사용이 가능하다.

- LOB은 각 TABLE의 LOB TYPE마다 개당 1개의 segment와 1개의 index segment를 자동으로 할당 받는다.

LOB Storage

- create table including LOB type

- lob_seg_name : 할당될 lob segment name 지정 (default : LOB$n)

- CHUNK : LOB data 저장단위, contiguous block으로 chain되는 각 chunk의 크기를 설정하기 위한 the number of blocks을 설정한다.

- PCTVERSION : RBS를 사용하지 않고 CHUNK의 몇%를 기존 transaction에서의 RBS처럼 사용하려는 비율을 설정한다. (또한 LOB 변경시 New Chunk 할당 후 Old Chunk는 RBS처럼 사용한다) indicates how much space the system will use for the LOB consistent-read(or versioning) mechanism. As soon as old versions of LOBs start to occupy more than the PCTVERSION amount of used LOB space Oracle will try to reclaim the old versions and reuse them.

- CACHE : LOB value read and write시 SGA buffer 사용

- NOCACHE LOGGING : doesn’t use SGA, allow log changes

[email protected] - 51 - 장 경상

SQL> create or replace type picture_type as object (image blob) ;SQL> create table person_tab ( pname varchar2(50), resume clob, picture picture_type) ;SQL> insert into person_tab values (‘Jang KS’, empty_clob(), picture_type(empty_blob()) ) ;

필요한 TYPE 과 CLOB

을 포함하는 table 생성

CLOB, BLOB 의 초기화

Data Insert

Create table apart_lob( floor_plan blob, contract clob, name varchar2(10))storage (initial ………) tablespace general_tbsLOB (floor_plan, contract) store as ( log_seg_name chunk 10 pctversion 20 nocache nologging tablespace lob_tbs storage(initial ….)INDEX( initrans 2 maxtrans 10 tablespace lob_ind storage(initial …..)) ;

Page 52: Oracle History #4

Oracle8 New Features http://www.ggola.com

- NOCACHE NOLOGGING : doesn’t use SGA, not allow log changes cache와 관련하여 특별이 기술되어 있지않을 땐 이 option이 default가 된다.

- LOB storage 나 index clause을 기술하지 않으면 default LOB clause은 다음과 같다.CHUNK : 1 database blockPCTVERSION : 10NOCACHE, NOLOGGING

Read consistency

- LOB data에 대한 concurrency

- Process 2개가 동일 LOB data에 대한 처리를 한다면…1은 select for update, 2는 select

1. process 1 lock row get lob locator : programmatic pointer인 locator를 select하고 read한 CHUNK를 variable로

2. process 2는 위와 동일한 CHUNK를 reading 중이다. (long running query)

3. process 1 read한 CHUNK(old chunk)를 LOB locator를 이용하여 update, new chunk saved, preserving the previous (old) chunk storageCF. new check가 할당된 후 old chunk는 PCTVERSION 비율에 따라 유지하면서 process2와 같은 transaction을 위해 RBS처럼 사용된다.

4. process2는 reselect LOB locator해야만 update된 new chunk를 볼 수 있다. 만일, process2가 old chunk를 계속 read하려 하면 PCTVERSION의 크기에 따라 성공하거나 아니면 ‘snapshot too old’ error를(.ORA-1555) return 받을 것이다.

[email protected] - 52 - 장 경상

Page 53: Oracle History #4

Oracle8 New Features http://www.ggola.com

External LOBs

Oracle8 provides a BFILE datatype to support an external or file-based large object: attribute in an object type or column values in a table

BFILE

- Definition of BFILE objects

- Association of BFILE objects to corresponding external files

- Security for BFILEs

- BFILE은 read-only이다. LOB이 delete되어도 file은 사라지지 않는다. File은 직접 O/S상에서 처리해야 한다.

- The BFILE locator maintains the directory alias, the filename, and some state information.

- Each row/column intersection can refer to a different file. The BFILE datatype is supported in the new PL/SQL package, DBMS_LOB, and in the Oracle8 OCI to enable stream I/O access to files residing on the server.(BFILE은 SGA를 거치지 않는다)

File Location and Access Privileges

- FILE은 database가 존재하는 machine에 있어야 한다.

- BFILE은 internal LOB처럼 read할 수 있으나 다음과 같은 restriction이 있다.1. access permissions2. file system space limits3. non-oracle manipulations of files4. OS maximum file size

- BFILE에 대한 transaction은 support하지 않으며, 따라서 BFILE에 대한 backup and recovery도 support하지 않는다.

[email protected] - 53 - 장 경상

SQL> create table home_page (empno REF employee_type,last_upt date, homepage BFILE) ;

SQL> create type person_info_type as object ( empno REF employee_type, picture BFILE, thumbprint BFILE, retinaprint BFIILE) ;

Page 54: Oracle History #4

Oracle8 New Features http://www.ggola.com

Directory Object

A new database item directory

- A directory item specifies an alias for a directory on the server’s file system.

- 이 directory에 대한 privileges를 grant함으로써 user별 보안관리가 가능하다.(Further, these directory can be used while referring to database files(open, close, read, and so on) in PL/SQL and OCI.

- Directory는 system or DBA에 의해 소유된다.(or a user with CREATE ANY DIRECTORY privilege)

- Directory object를 생성할 대에는 O/S상의 FILE유무를 확인하지 않는다. 실행시점에서만 사용한다.

- BFILE access errors1. directory object에 대한 access privileges가 없는 users2. directory alias에 mapped directory가 실제 존재하지 않거나 oracle이 file을 access하는데 필요한 required privileges set이 없는 경우.3. 실제 file이 존재하지 않는 경우

- Privileges : CREATE ANY DIRECTORY,DROP ANY DIRECTORY,grant or revoke on directory directory_name to xxx ;

Guidelines

- Directory를 만들 때 database file을 함께 지정하지 마라. Directory는 path일 뿐이다.

- Create any directory, Drop any directory는 system privileges이므로 가급적 carefully하게 다루고, 일반적인 다른 users에게는 grant하지 않도록 하라.

- 가급적 O/S상의 path를 미리 만들어 놓고 directory object를 만들도록 하라.

다른 O/S로 database migration을 한다면 미리 directory object에 대한 처리를 해야 할 것이다.

[email protected] - 54 - 장 경상

$[/app/oracle/admin/work] mkdir fileSQL> create directory lob_path as ‘/app/oracle…/file ;SQL> grant read on directory lob_path to scott ;

Page 55: Oracle History #4

Oracle8 New Features http://www.ggola.com

Managing LOBs

General method for an internal LOB

1. LOB datatype을 가진 table 생성

2. 프로그램내에서 declare and initialize the LOB locator

3. Select for update사용하여 LOB을 가진 row를 lock

4. Manipulate the LOB with DBMS_LOB or OCI

5. Commit

External LOB

1. O/S directory 생성 및 Oracle에 directory permission 부여

2. 대상 directory에 대상 file을 load

3. BFILE을 가진 table 생성

4. Directory item을 만들고 permissions을 grant

5. Insert rows into the table

6. 프로그램내에서 declare and initialize the LOB locator

7. LOB locator를 이용하여 Select the row and column을 통해 BFILE을 access

8. Read BFILE with the LOB with DBMS_LOB or OCI, using the locator as a reference to the file

Populating LOBs

- LOB column update는 setting it to another LOB value, NULL, or using empty function을 통해서 할 수 있다. you can update the LOB using a bind variable in embedded SQL, the value of which may be NULL, empty, or populated.동일한 크기의 LOB을 다른 것으로 set할 때에는 a new copy of the value가 만들어지므로 LOB에 미리 lock을 잡는 경우는 LOB의 일부분 즉, a piece of the LOB을 update할 때 뿐이다.

[email protected] - 55 - 장 경상

SQL> insert into person_tab values ( ‘Jang KS’, empty_clob(),picture_type(empty_blob()) );

SQL> update person_tab set resume =(select resume from persong_tab where pname=‘Park KS’)where pname = ‘Jang KS’ ;

Page 56: Oracle History #4

Oracle8 New Features http://www.ggola.com

Removing LOBs

- deleted BFILE은 explicitly remove해야 한다.

Accessing LOBs

- LOB value를 access하기 위해서는 PL/SQL DBMS_LOB package or OCI or Pro*C를 사용해야 한다.

- Select 문장은 LOB locator만을 return할 뿐이다.

- LOB value의 일 부분을 update할 때는 explicitly select for update를 사용해 lock을 잡아야 한다.

DBMS_LOB Package

DBMS_LOB

- by sys user dbmslob.sql and prvtlob.plb scripts를 수행하거나 catproc.sql script를 수행해야 생성된다.

[email protected] - 56 - 장 경상

SQL> Declare Lobloc CLOB ; Buffer varchar2(1000) ; Amount number := 1000 ; Offset integer :=25 ; Begin Buffer := ‘KS loves Oracle8’ ; Amount := length(buffer) ; Select resum into lobloc from person_tab where pname = ‘JE

knows oracle7 well’ for update ; DBMS_LOB.WRITE(lobloc, amount, offset, buffer) ; END ; /

Offset : 시작위치

Buffer : 실제 data

SQL> delete from person_tab where pname = ‘Park KS’ ;SQL> update person_tab set resume = empty_clob()

where pname = ‘JE knows oracle7 well’ ;

SQL> Declare Lob_loc_var CLOB ; Begin Select resume into lob_loc_var from person_tab

where pname = ‘JE knows oracle7 well’ ; END ; /

Page 57: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 이 package는 does not support any concurrency control mechanism for BFILE operation.

- Do not implicitly lock the row containing the LOB

- Mutators : append, copy, erase, trim, write, fileclose, filecloseall, fileopen, loadfromfileObservers : compare, filegetname, instr, getlength, read, substr, fileexists, fileisopen

- Argument가 null이면 항상 null을 return할 것이다. All mutator procedures는 destination LOB/BFILE is input as null이면 raise exception할 것이다.

- Offsets은 반드시 positive만 허용하며 이는 LOB data의 operation을 start 하기위한 byte/character의 수를 나타낸다. offset의 default는 1이고 이는 LOB value의 first byte/character를 가리킨다. BLOB, BFILE 은 bytes로 CLOB/NCLOB은 character로 표시한다.

APPEND, COMPARE

SQL> DBMS_LOB.APPEND(dest_lob in out BLOB|CLOB, src_lob in BLOB|CLOB) ; procedure

- src_lob을 dest_lob에 append

SQL> DBMS_LOB.COMPARE(file_1|lob_1 in BFILE|BLOB|CLOB, file_2|lob_2 in BFILE|BLOB|CLOB,amount in integer := 4294967294,offset_1 in integer := 1 ,offset_2 in integer := 1) ; function : return integer

- LOB type의 data를 completely 비교한다.

- Return : 0 (equal), -1 (first value is less), 1 (first value is greater)

- Amount bytes만큼 비교를 하며 비교를 시작하는 위치는 offset에서 정한다. CLOB인 경우 비교대상은 동일한 character-set이라고 가정한다.

COPY, ERASE

SQL> DBMS_LOB.COPY( dest_lob in out BLOB|CLOB, src_lob in BLOB|CLOB, amount in integer,

[email protected] - 57 - 장 경상

Page 58: Oracle History #4

Oracle8 New Features http://www.ggola.com

dest_offset in integer :=1, src_offset in integer :=1) ; procedure

- src_lob에 대하여 지정된 offset에서 amount만큼 copy하여 dest_lob의 offset에 paste한다.

- dest_offset이 LOB data의 끝이면 zero-byte(space) fillers를 넣고 그 뒤에 copy한다.

SQL> DBMS_LOB.ERASE( lob_loc in out BLOB|CLOB, amount in out integer, offset in integer := 1) ; procedure

- 지정된 offset에서부터 amount만큼 data를 지운다.

- 지워진 number는 다시 amount variable로 return되는데 만일, input amount number만큼 지워지기 전에 LOB data의 끝에 달하면 그때까지 지워진 number만큼만 return된다.

- 만일, 지워지는 data양이 LOB data의 중간에서 어느 부분만 해당된다면 data가 지워진 후 그 위치에 0-byte space fillers를 채워넣는다.

FILECLOSE, FILECLOSEAL, FILEEXISTS, FILEGETNAME

SQL> DBMS_LOB.FILECLOSE(file_loc in out BFILE) ; procedure

- 이미 opened BFILE을 close한다.

SQL> DBMS_LOB.FILECLOSEALL ; procedure

- currently open BFILEs를 모두 close한다.

SQL> DBMS_LOB.FILEEXISTS(file_loc in BFILE) ; function : return integer

- 실제로 file이 존재하는가 확인

- return : 1 (file exists), 0 (does not exists)

SQL> DBMS_LOB.FILEGETNAME(file_loc in BFILE, dir_alias out varchar2, filename out varchar2) ; procedure

- 주어진 BFILE locator를 이용하여 directory alias와 filename을 지정한 변수로 return해 준다.

[email protected] - 58 - 장 경상

Page 59: Oracle History #4

Oracle8 New Features http://www.ggola.com

FILEISOPEN, FILEOPEN, LOADFROMFILE

SQL> DBMS_LOB.FILEISOPEN( file_loc in BFILE) ; function : return integer

- BFILE이 open되어 있는가(via the input locator) 확인

SQL> DBMS_LOB.FILEOPEN( file_loc in out BFILE, open_mode in binary_integer := file_readonly) ; procedure

- BFILE을 open mode로

SQL> DBMS_LOB.LOADFROMFILE(dest_lob in out CLOB|BLOB, src_file in BFILE, amount in integer, dest_offset in integer := 1, src_offset in integer := 1) ; procedure

- external LOB data를 copy하여 internal LOB으로 load

GETLENGTH, INSTR

SQL> DBMS_LOB.GETLENGTH( lob_loc in BFILE|BLOB|CLOB) ; function : return integer

- 지정한 LOB의 길이를 확인. Empty면 0을 아니면 길이를 return한다.CF. o-byte space fillers도 length에 포함된다.

SQL> DBMS_LOB.INSTR( lob_loc in BFILE|BLOB|CLOB, pattern in raw|varchar2, offset in integer := 1, nth in integer := 1) ; function : integer

- 주어진 pattern과 일치하는 value가 있는지 확인하여 matching position을 찾아준다.CF. CLOB의 경우 character set은 일치한다는 전제가 필요하다. (따로 character set을 check하지는 않는다)

READ, SUBSTR

SQL> DBMS_LOB.READ( lob_loc in BFILE|BLOB|CLOB,amount in out binary_integer,offset in integer,buffer out raw|varchar2) ; procedure

- LOB에서 부분적인 read가 필요할 때 사용되며 offset부터 amount만큼의 data를 return한다. Amount만큼 read이전에 LOB data의 끝에 다다르면 그때까지의 data만 return한다.

[email protected] - 59 - 장 경상

Page 60: Oracle History #4

Oracle8 New Features http://www.ggola.com

- PL/SQL allows a maximum value of 32767 for RAW and VARCHAR2 constraints.

SQL> DBMS_LOB.SUBSTR( lob_loc in BFILE|BLOB|CLOB,amount in integer := 32767,offset in integer := 1) ; function : return raw|varchar2 (raw for BFILE, BLOB)

- 주어진 offset부터 amount만큼의 bytes or character length만큼의 a part of LOB value를 return하나 READ procedure와 달리 SQL문에서 사용이 가능한 function이다.

TRIM, WRITE

SQL> DBMS_LOB.TRIM( lob_loc in BLOB|CLOB,newlen in integer) ; procedure

- 지정한 newlen 만큼 LOB value를 trim한다. 이 procedure는 empty LOB에 사용해도 무방하지만 newlen을 negative로 지정하는 경우는 raise exception 된다.

SQL> DBMS_LOB.WRITE( lob_loc in BLOB|CLOB,amount in out binary_integer,offset in integer := 1,buffer in raw|varchar2) ; procedure : buffer raw for BLOB

- 지정하는 amount만큼 부분적인 write를 위해 사용될 수 있다.

Export/Import for LOBs

CLOB import시 importer’s default character set으로 convert.

The server converts NCLOB from the character set of export dump file into the national character set of the target database.

BLOB은 convert되지 않으며 BFILE의 경우 name and directory aliases만 export되므로 실질적인 file은 O/S상에서 옮겨주되 location을 맞추던지 아니면 directory aliases를 new location으로 update해야 한다.

[email protected] - 60 - 장 경상

Page 61: Oracle History #4

Oracle8 New Features http://www.ggola.com

8. Implementing Oracle Advanced Queuing

Queuing

Business process management and workflow are more and more recognized as fundamental technologies for emerging applications.CF. OLTP에서도 online and connected execution job 뿐만이 아니라 deferred or disconnected execution이 더 중요한 혹은 더 낳은 요구들이 대두되고 있다.

이러한 요구에 부응하는 queuing은 even in the presence of application and system failures에서도 exactly once process 되어야 하는 점이 매우 중요하다.

Oracle은 TP monitor에 의존적이지 않고 message-oriented middleware(MOM) infrastructure를 evolving하는 efficient queuing infrastructure를 제공한다.

Oracle8 is the first message-enabled database.

Message

Represents the smallest unit of work processed by a single transaction.(unit of information being inserted into and retrieved from a queue)

User(payload) data and control information으로 구성된다.

하나의 transaction이 multiple messages를 만들고 처리할 수 있다. ENQUEUE procedure로 만든다. DEQUEUE procedure로 처리한다.

Message Queues

- Message queues는 a collection of messages

- ENQ, DEQ는 store or retrieve를 위해 only one queue만 access한다.CF. 각 message는 a single queue에만 속해야 한다.

- Queue 생성시 name을 부여함으로써 user or application이 reference할 수 있다. Queues의 수에는 제한이 없다.CF. DBMS_AQADM package를 이용하여 다양한 tasks를 수행할 수 있다. (creation, alter, start, stop, drop…)

[email protected] - 61 - 장 경상

Page 62: Oracle History #4

Oracle8 New Features http://www.ggola.com

Queue Table

- Regular table이고 개수에 제한이 없다.

- 각 queue table은 하나 이상의 queues를 hold할 수 있다.CF. DBMS_AQADM package를 이용하여 queue table을 만들 수 있다.

Benefits of Oracle Advanced Queuing

- Reliable, Persistent queuing, Improved Performance, Simplified Operations

- Message를 after consumption에도 retain 시킬 수 있도록 Retention을 제공함으로써 history를 통해 tracking, data warehouse, data mining operations에 사용할 수 있다.1. 처리되었건 아니건 retrieve any message in a coherent way with familiar tools2. discover relation between messages3. discover patterns in content and traffic of messages

Features of Oracle/AQ

- ordering of messages, prioritizing of messages, correlation identifier, time constraints, object types as messages, reply queue, exception queue, nontransactional and transactional request, browsing of messages, multiple recipients, message grouping

DBMS_AQ.ENQUEUE

DBMS_AQ holds two procedures – ENQUEUE & DEQUEUE(add a message & retrieve a message)

Initially, only SYS user에게 procedures권한이 있다. 따라서 다른 user가 이 package를 사용하기 위해선 SYS user가 권한을 주어야 한다. 이런 경우 AQ_USER_ROLE로 만들어진 ROLE을 grant하여 일괄적으로 관리할 수 있다.

DBMS_AQ.ENQUEUE Procedure

SQL> DBMS_AQ.ENQUEUE(queue_name in varchar2,enqueue_options in enqueue_option_t,message_properties in message_properties_t,payload in <object_type|raw>,msgid out raw) ;

- add a message to a queue specified by the user

[email protected] - 62 - 장 경상

Page 63: Oracle History #4

Oracle8 New Features http://www.ggola.com

- enqueue_options and message_properties are both predefined record types.payload cab be specified as an object type or a raw.(Object type attributes maximum number는 900개까지 허용하며 raw type인 경우 32KB까지 가능하다)

- sample

Q_NAME

- message를 enqueue할 queue name을 지정한다. 가장 simple한 queue는 queue name 과 payload만 지정하면 된다.EX) queue_name => ‘SCOTT.Q_MSG’

ENQUEUE_OPTIONS

- options 정의EX) enqueue_options => ENQUEUE_OPTS_REC

- parameter1. visibility transaction behavior ON_COMMIT : part of the current transaction IMMEDIATE : not part of the current transaction2. relative_msgid sequence_deviation의 값에 따라 읽어야 할 message의 identifier3. sequence_deviation queue에 이미 있는 message가 언제 enqueued되는가 지정. BEFORE : ahead of the message specified by relative_msgid TOP : ahead of any other messages NULL : Default

[email protected] - 63 - 장 경상

TYPE ENQUEUE_OPTIONS_T IS RECORD(

VISIBILITY binary_integer defatult ON_COMMIT,

RELATIVE_MSGID raw(16) default NULL,

declaremesg_hndl raw(16);message aq13.message_type;enqueue_options dbms_aq.enqueue_options_t;message_properties dbms_aq.message_properties_t;

beginenqueue_options.visibility := dbms_aq.immediate;message := aq13.message_type('Claus','Ray will arrive

later');dbms_aq.enqueue(queue_name => 'mail_queue',

enqueue_options => enqueue_options,message_properties => message_properties,payload => message,msgid => mesg_hndl);

end;/

Page 64: Oracle History #4

Oracle8 New Features http://www.ggola.com

MESSAGE_PROPERTIES

- 특성지정

- RECORD

- parameter 1. priority 우선순위를 지정하는 숫자로 dequeue의 순서가 된다. Negative numbers도 포함한다. 2. delay enqueued message delay를 지정한다. Default는 NO_DELAY이고 delay할 message의 the number of seconds를 지정할 수 있다. 3. expiration message의 만기를 설정할 수 있다. default는 Never이고 second단위로 지정하여 지정된 시간만큼 READY상태로 대기하며 그 시간이 지나면 EXPIRED 상태로 exception queue로 이동한다. 4. correlation the identification supplied by the producer for a message at enqueuing 5. attempts message를 dequeue하기위한 the number of attempts를 지정. This parameter cannot be set at enqueue time. 6. recipient_list This parameter is only for queues which allow multiple consumers. 7. exception_queue 성공적으로 처리되지 못한 message를 이동시켜 놓는 queue name으로 dequeue attempts을 초과해서 실패한 경우와 expiration으로 인해 실패한 경우가 있다. 8. enqueue_time the time the message was enqueued. user가 아닌 system에서 결정되는 parameter로 enqueue time에 결정될 수 없다. 9. state dequeu시의 message state를 표시. WAITING : has not yet been reached READY : ready to be processed PROCESSED : has been processed and is retained EXPIRED : has been moved to the exception queue

[email protected] - 64 - 장 경상

TYPE MESSAGE_PROPERTIES_T IS RECORD (

PRIORITY binary_integer dfault 1,

DELAY binary_integer default NO_DELAY,

EXPIRATION binary_integer default NEVER,

CORRELEATION varcahr2(128) default NULL,

ATTEMPTS binary_integer,

Page 65: Oracle History #4

Oracle8 New Features http://www.ggola.com

CF. type aq$_recipient_list_t is table of sys.aq$_agent index by binary_integer

CF. type sys.aq$_agent is object ( name varchar2(30), address varchar2(30), protocol number)

PAYLOAD/MSGID

- payload can be an object type defined by the user or a raw

- msgid returns a globally unique identifier of the message that has been enqueued. all enqueues는 message id를 return해야 하고 handle for subsequent operations on the message로 사용될 수 있다.

DBMS_AQ.DEQUEUE

DBMS_AQ.DEQUEUE Procedure

SQL> DBMS_AQ.DEQUEUE(queue_name in varchar2,dequeue_options in dequeue_option_t,message_properties out message_properties_t,payload out < type_name>,msgid out raw) ;

- dequeue_options, message_properties are both predefined record types.

- Only messages in the READY state are dequeued unless a msgid is specified.

- sample

[email protected] - 65 - 장 경상

declaredequeue_options dbms_aq.dequeue_options_t;message_properties dbms_aq.message_properties_t;message_handle RAW(16);message aq13.message_type;

begin dequeue_options.wait := dbms_aq.no_wait;

dequeue_options.navigation := dbms_aq.first_message;dbms_aq.dequeue(queue_name => 'mail_queue',

dequeue_options => dequeue_options,message_properties => message_properties,payload => message,msgid => message_handle);

dbms_output.put_line('The dequeued message is "'||message.text||'" please notify '||message.recipient);

end;/

Page 66: Oracle History #4

Oracle8 New Features http://www.ggola.com

Q_NAME

- message를 dequeue할 queue name을 지정한다.

DEQUEUE_OPTIONS

- predefined record

- parameter 1. consumer_name consumer name (multiple consumer를 사용하지 않는다면 NULL) 2. dequeue_mode locking behavior를 지정한다. BROWSE : locking없이 read message (select와 동일) LOCKED : read and obtain a write lock on the message REMOVE : read message and update or delete (this is the default) 3. navigation retrieve할 message position을 지정. 먼저 position을 찾고, search criterion을 정한 후, retrieve message NEXT_MESSAGE : retrieve the next message (this is the default) NEXT_TRANSACTION : skip current transaction and retrieve the first message of the next transaction group. FIRST_MESSAGE : retrieve first message. This will reset the position to the beginning of the queue. 4. visibility specifies whether the new message is dequeued as part of the current transaction. (BROWSE mode에서는 무시된다) ON_COMMIT : part of current transaction IMMEDIATE : not part of current transaction 5. wait wait time을 지정한다. FOREVER : wait forever (this is the default) NO_WAIT : do not wait number : wait time in seconds 6. msgid message identifier 지정 7. correlation correlation identifier of the message 지정

[email protected] - 66 - 장 경상

TYPE DEQUEUE_OPTIONS_T IS RECORD(

CONSUMER_NAME varchar2(30) defatult NULL,

DEQUEUE_MODE binary_integer default REMOVE,

NAVIGATION binary_integer default NEXT_MESSAGE,

VISIBILITY binary_integer default ON_COMMIT,

Page 67: Oracle History #4

Oracle8 New Features http://www.ggola.com

MESSAGE_PROPERTIES

- This is output argument.

- ENQUEUE procedure의 message_properties 참조

PAYLOAD/MSGID

- payload is an out argument as well as msgid. Payload는 queue table생성시 사용된 object type을 기반으로 한다. 만일, queue table생성시 object type이 사용되지 않았다면 raw datatype으로 간주한다.

- ENQUEUE procedure의 payload & msgid 참조

AQ_TM_PROCESSES

A timer process is required for any message that requires a delay, expiration, or timed retention support.

Init.ora에서 AQ_TM_PROCESSES를 지정한다.

parameter 사용할 때는 1로 그렇지 않으면 0을 설정하거나 아예 설정을 하지 않는다. 만일 1을 넘는 수를 지정하면 error를 return하고 time manager는 생성되지 않을 것이다.

DBMS_AQADM

you manage configuration information through the package procedures in the DBMS_AQADM package.

최초에는 SYS user에게만 권한이 있으며 필요한 경우 AQ_ADMINISTRATOR_ROLE을 사용하여 grant할 수 있다.

DBMS_AQADM Procedures

- CREATE_QUEUE_TABLE, DROP_QUEUE_TABLE, CREATE_QUEUE, DROP_QUEUE, ALTER_QUEUE, START_QUEUE, STOP_QUEUE

- START_TIME_MANAGER, STOP_TIME_MANAGER, ADD_SUBSCRIBER, REMOVE_SUBSCRIBER, QUEUE_SUBSCRIBERS

[email protected] - 67 - 장 경상

Page 68: Oracle History #4

Oracle8 New Features http://www.ggola.com

관련 Views

DBA/USER_QUEUE_TABLES : information of table queues

DBA/USER_QUEUES : information of individual queues

aq$<queue_table_name> : a view for each queue table

[email protected] - 68 - 장 경상

Page 69: Oracle History #4

Oracle8 New Features http://www.ggola.com

9. Using Additional New Features

Constraints

Creating Constraints

SQL> create table tname ( col1 … constraint consname …1. NOT DEFERRABLE (default)2. DEFERRABLE 2.1 INITIALLY IMMEDIATE (default) 2.2 INITIALLY DEFERRED, col2 varchar2(10), col3 ……) ;

- table 생성시 1 or 2.1 or 2.2의 형태로 Key를 구성하여 deferred checking을 결정할 수 있다.

- 1은 기존 방식의 default이므로 항상 check를 하고 2.1은 deferred checking을 선언하는 default로 ALTER SESSION command나 SET command를 통하여 deferred checking을 제어 할 수 있고 2.2는 2.1에서 필요한 command없이 항상 deferred하게 처리가 가능한 방식이다.

- Parent & Child로 구성된 emp & dept의 key를 2.1로 형성을 했다면 다음의 과정을 통해 dept가 child임에도 먼저 insert작업등을 할 수 있다.SQL> alter session set constraints = deferred ; (또는 set constraint consname ; 또는 set constraint all deferred ; )SQL> insert into dept values ( … ‘001’, ……) ;SQL> insert into emp values (‘001’, ….) ;SQL> commit ;CF. 물론 2.2와 달리 2.1은 set command가 없는 경우 1과 동일한 constraint checking을 한다.CF. 또한 constraint란 FK뿐만 아니라 CHECK, UK, PK등을 포함한다는 것을 명심하자.

Enforced constraints

- Disable : data는 enable시 모두 constraint check되어야 한다.CF. creation command에서도 사용할 수 있으므로 이미 data가 있는 경우에 유용하게 쓰일 수 있다.

- Enable : all data and new added data모두 constraint check가 되어야 한다.

[email protected] - 69 - 장 경상

Page 70: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Enforced : 현재 존재하는 data는 violate constraint일 수 있으나 new added data 혹은 modified data는 constraint check가 되어야 한다.CF. Disable로 Creation하고 Enforce하면 old data를 무시하고 constraint를 enable할 수 있게된다.

SQL> alter table tname disable/enable/enforce constraint consname ;

- Once enforce되면 lock없이 enable이 가능하며 대상 table에 대한 reading and updating이 있어도 enable될 수 있다. 또한 concurrently로 다수의 constraints를 enforce할 수 있다.

- Enforced constraints are useful for unique constraints when a unique or nonunique index exists that can be used to enforce the index if Oracle has to create an index, there is no real gain.

- Same issue for primary key constrains. However, the NOT NULL check will be faster to enable.(Foreign key, Not Null, Check), the enforced constraints provide major benefits in terms of data availability during the enforce phase.

CF. 위 부분은 Oracle8의 각 version(8i포함)별로 다르게 다루어지고 있으므로 각 version에 맞는 학습이 필요하다.

Nonunique Index

- UK or PK constraints enforce를 위해 nonunique index를 사용할 수 있다. 물론 이 index는 unique column으로 만들어져야 하고 반드시 첫번째 column은 unique column이 와야 한다. 이 index를 사용하여 enforce된 UK or PK constraint는 disable되도 drop 되지 않는다.CF. PK or UK의 enforce 사용을 위해서 nonunique index를 고려해보자.

Indexes

Reverse Index

SQL> create index iname on tname (col_no, col_no2) reverse ;

- reverse index는 each column of index의 bytes를 거꾸로 만든다. 단, ROWID는 그대로이고 column순서도 바뀌지 않는다.

[email protected] - 70 - 장 경상

Page 71: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Useful in parallel server environment에서 index modification이 a small set of leaf blocks에 집중되는 경우 한 table에서 ascending values를 insert하고 lower values를 delete하는 경우

- Rebuild를 사용해서 다시 바꿀 수도 있다.

SQL> alter index iname rebuild noreverse/reverse ;

CF. index column의 values가 ‘101’, ‘102’ ,’103’의 형태로 저장된다면 index의 leaf block은 한 쪽으로 편향될 것이다. 이러한 경우 reverse를 이용하면 ‘101’, ‘201’, ‘301’의 형태로 저장되므로 leaf block을 분산시킬 수 있다.CF. reverse index는 저장이 reverse로 되기 때문에 “=” 즉, equality 비교만 가능하다. (대소비교는 할 수 없다)

Index-Only Tables

- data와 index를 분리하지 않고 table자체를 B-tree형태로 저장한다. 따라서 index가 따로 필요하지 않게 되므로 전체적인 면에서 볼 때 storage를 minimize하는 효과가 나타날 수 있다.

- Standard Indexing :data는 순서가 없이 database block으로 저장되고index는 B-tree 구조로 maintain 된다. Index values는 indexed values and ROWID로 구성된다. 따라서 highly efficient이다. 그러나 어쨌든 index and data block을 읽어야 하고 index key values는 중복저장이 되며 복잡한 data를 사용하는 경우 varied indexing approaches가 필요하다.

- Index-Only Indexing :all data는 B-tree구조로 저장되고 information retrieval, spatial applications, online analytical processing applications에 유용하다.CF. PK가 반드시 존재해야 하며(ROWID가 없다) where절에 주로 PK+다른 1column으로 사용되는 경우에 매우 유용하다.

SQL> create table tname ( col1 varchar2(10), col2 number, col3 ind_desc varchar2(20), constraint pktname primary key(col1, col2)) organization index/heap tablespace ts_ind_ontable pctthreshold 20 overflow tablespace ts_text ;

- standard oracle tables의 경우 즉, default는 organization heap이고 index-only table은 organization index option을 사용한다. 또한 large values를 위해 overflow area를 지정할 수 있다.

[email protected] - 71 - 장 경상

Page 72: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Row Overflow : index block에 large rows를 저장하면 full index scans시 느려질 수 있다. 이러한 경우 nonkey columns을 overflow영역으로 지정한 area에 따로 저장할 수 있다.(default는 user’s default tablespace)

- THRESHOLD : threshold value를 setting하여 overflow기준을 지정 할 수 있는데 이는 block size의 percent표현으로 예를 들어 30이라면 저장되는 row의 size가 block size의 30%이상인 경우 overflow 영역으로 이동한다.(default는 50이다) 물론, overflowed columns에 대한 pointer를 남긴다. 이는 ‘B-tree itself remains densely clustered.’를 의미한다.

- 위의 예는 col1과 col2로 PK를 생성하는 index-only table(organization index)이고 data는 ts_ind_ontable tablespace에 저장되며, block size의 20%가 넘는 row의 nonkey columns(PK가 아닌)은 ts_text tablespace에 저장된다.CF. including columns을 이용하여 overflow를 시키지 않을 columns을 지정할 수 있다.

- Index-only table의 생성으로 _tables views에 IOT column이 추가 되었다. 이 column에는 IOT for index-only tables, IOT_OVERFLOW for overflow segment, NULL for all other tables가 올 수 있다.CF. In the current release, the overflow part of an index-only table shows up in DBA_TABELS or in the other TABLES views as a separate segment with a system-generated name such as SYSIOT_OVER_1909.

- Restriction : must have primary key, 다른 index는 사용불가, unique constraints를 사용할 수 없고, clustered될 수 없고, long column을 가질 수 없으며, replication or partitioning을 지원하지 않는다.CF. table operation은 일반 table과 다른 것이 없으나 다만 ROWID를 활용할 수는 없다.

Security Enhancements

Can no longer connect to SYS without SYSDBA options.

Must belong to the OSDBA group, or the password must match the password for SYS/internal in the password file.

이제 Oracle8부터는 더 이상 ANY를 포함하는 system privilege로 SYS schema objects에 access할 수 없다.

[email protected] - 72 - 장 경상

Page 73: Oracle History #4

Oracle8 New Features http://www.ggola.com

SYS schema objects에 access, execute, delete의 작업을 원한다면 Special roles인 SELECT_CATALOG_ROLE, EXECUTE_CATALOG_ROLE, DELETE_CATALOG_ROLE 을 grant되어야 한다.

Large Pool

SGA외에 별도의 memory를 할당할 수 있다.

Large Pool Memory

- Used for session memory(UGA) for MTS or XA, I/O slaves, ( DBWR, LGWR, ARCH등 I/O 발생 processor)Oracle backup and restore ( RMAN등)

- I/O slaves and Oracle backup and restore는 a few hundred KB in size이 buffer할당을 함으로 이를 만족시키기 위해 large pool이 사용될 수 있다.

- 이 memory는 LRU 알고리즘을 사용하지 않는다.

SIZE

- LARGE_POOL_SIZE : memory 할당 size (K or M)minimum 300K or LARGE_POOL_MIN_ALLOC중 더 큰 것maximum 최소 2GB 가능 (OS dependent)default 0

- LARGE_POOL_MIN_ALLOC : large pool에 할당할 최소 할당 size in bytes (K or M으로 지정할 수도 있다)default 16K, minimum 16K, maximum 64M

- 관련 parameterSHARED_POOL_SIZESHARED_POOL_RESERVED_SIZESHARED_POOL_RESERVED_MIN_ALLOC

National Language Support

character set을 이용한 변수 선언

NCHAR

- 고정된 character length로 database character set의 subset

[email protected] - 73 - 장 경상

Page 74: Oracle History #4

Oracle8 New Features http://www.ggola.com

- provides better performance for multibyte character set

- contains the national character set, which is part of the create database statement.

- 2000 bytes까지 선언할 수 있다.

NVARCHAR2

- NCHAR과 동일하나 varchar2, char의 차이처럼 variable size로 4000 bytes까지 선언할 수 있다.

N type 사용하기

- 비교하거나 입력할 때 N이라는 접두어를 사용해야 한다.CF. select * from emp where ename = N’xxxx’ ;

External Procedure

external procedure는 특별한 목적을 가지고 수행되는 3GL routine 이다.

Callout, Callback

- PL/SQL or SQL 내부에서 external procedure를 call한다.

Benefits

- Integration : PL/SQL engine으로의 3GL programs 통합이 가능하며, enabling transparent access to these procedures from within the database.

- Extensibility : provide functionality in the database that is specific to a particular application, company, or technological area.

- Reusability : database의 all users에 대하여 공유가 가능하다. 뿐만 아니라 moved to other database or computers.따라서 providing standard functionality with limited cost in development, maintenance, and deployment.

Components

1. server process가 PL/SQL subprogram을 실행하여 외부로 연결되어 있는 library object인 ‘alias’를 찾는다.

2. PL/SQL subprogram이 listener에게 request를 pass한다.

[email protected] - 74 - 장 경상

Page 75: Oracle History #4

Oracle8 New Features http://www.ggola.com

3. listener process는 spawns the extproc process 하고 oracle session을 통해 the extproc process는 active상태가 된다. (log off시점까지)

4. the extproc가 shared library를 load한다.

5. the extproc가 external procedure를 실행하고 그 결과를 PL/SQL subprogram에게 return한다.

Library

- alias library는 external shared library를 map하는데 사용된다.

- 해당 user는 반드시 alias library에 대한 execute privilege가 있어야 access할 수 있다. (library creation을 위해서는 create library or create any library privileges가 있어야 한다)CF. 이들 정보는 USER_LIBRARIES, ALL_LIBRARIES 참조

SQL> create or replace library lib_name is ‘filespec’ ;SQL> grant execute on lib_name to username ;

CF. library creation시 지정하는 file specification은 ‘create library’시점에서는 그 location정보를 확인하지 않는다. 만일 실수가 있었다면 runtime시 error가 발생할 것이다.

Listener Process

- external procedure는 dynamic library형태로 존재하며 extproc process가 그것을 load하고 실행한다.

- extproc process는 user log off시점까지 external procedures를 실행 service를 담당한다. 각 session은 different extproc process를 사용하여 external procedures를 실행한다.

EX) 다음은 listener process에 connecting할 entry를 포함하는 sample이다. The entry is named “extproc_connection_data” and is predefined. You must use this name.

[email protected] - 75 - 장 경상

Tnsnames.ora

extproc_connection_data=

(DESCRIPTION =

(ADDRESS=(PROTOCOL=IPC) (KEY=ORACLE8))

(CONNECT_DATA=(SID=ORACLE8)

)

Listener.ora

LISTENER =

(DESCRIPTION_LIST = (DESCRIPTION =

Page 76: Oracle History #4

Oracle8 New Features http://www.ggola.com

Reconfirmation of new features

CHAR/NCHAR 2000 bytes 까지

VARCHAR2/NVARCHAR2 4000 bytes 까지

Table내 maximum columns 수는 1000개 까지

생성 가능한 tablespace수는 64KB 만큼

Database size는 512PB (펩타바이트)까지

Tablespace당 datafile 최대개수는 1022개 까지

Indexed columns의 최대개수는 32개 까지

[email protected] - 76 - 장 경상

Page 77: Oracle History #4

Oracle8 New Features http://www.ggola.com

10. Introduction to Recovery Manager (RMAN)

Recovery Manager

is both a standalone utility and an embeddable library inside the Oracle8 Server using a special PL/SQL interface for database files backup, recovery, and restore functions

The recovery catalog is a repository of information that is used by Recovery Manager for managing backup and restore operations..

Benefits

- backup시 database 뿐만 아니라 individual tablespaces or datafiles backup도 가능하다.

- Incremental backup 가능 (changed blocks만 backup 가능)

- 적절한 scheduling과 여러 형태의 backup방법을 지원 (configuring frequently executed backup operations and backup operations for later execution)

- restore media and recovery operations의 자동화

- backup and recovery actions에 대한 printable log generation

- backup and restore에 대한 parallelization 지원

- unused blocks에 대하여 backup을 받지 않도록 설정가능. (단, 이 경우 다른 backup본과 달리 restore시 반드시 RMAN을 통해서 restore를 해야 유효한 backup본이 된다)

- backup, recover, and restore operations을 위한 thirty-party vendor storage subsystems을 사용할 수 있다.

RMAN Operation Type

- RMAN은 명확히 Oracle8 Server에 통합된 utility이지만 command line 뿐만 아니라 OEM을 통한 GUI 환경도 지원한다.

- Command line interpreter (CLI) : SQL*Plus같은 standalone application로 interactive mode 및 batch mode 모두 지원한다.

[email protected] - 77 - 장 경상

Page 78: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Graphic User Interface (GUI) : OEM에 통합된 RMAN, All of the functions available through the command language are available through the API.

Catalog

Recovery catalog

- Recovery catalog는 일종의 repository of information으로 RMAN에 의해 maintained(유지/보수)된다.

- Recover catalog의 내용은 다음과 같다.1. datafiles and archivelog backup sets and backup pieces.2. datafile copies.3. archived redo logs and copies of them.4. the physical structure of the target database5. named sequences of commands that call stored scripts

- Recovery catalog는 RMAN에 활성화되기 전에 install되어야 한다. ($ORACLE_HOME/rdbms/admin/catrman.sql)

- 안정성을 위해 catalog자체도 backup을 받아야 하며 이 또한 RMAN으로 backup될 수 있다. 일반적으로 두개의 서버에서 서로간 recovery catalog를 backup받아 사용할 수 있다. 한쪽은 recovery catalog database, 다른 한쪽은 target database가 될 것이다. 따라서 restore가 실행되면 recovery catalog에서 appropriate information을 가져와서 이를 database server로 옮겨준다. 대부분의 information은 target database control file에서 가져오지만 rollback segment information같은 정보는 target database가 open된 상태에서만 가져올 수 있다.CF. database structure changes가 발생하면 반드시 catalog에 대한 resync작업이 필요하다.

- Recovery catalog는 오직 RMAN에 의해서만 접근이 허용되며 Oracle directly access할 수 없지만, RMAN으로 인한 incorrect behavior으로 database가 corrupted되지는 않으며 또한 recovery catalog없이 작업이 될 수 있도록 operational mode를 지원한다.

Operation without a Recovery Catalog

- Recovery catalog를 운영하는 것이 부담이 될 때

- If you have to recover a database without using a recovery catalog, most of the necessary information can be obtained from the controlfile of the targeted database.

[email protected] - 78 - 장 경상

Page 79: Oracle History #4

Oracle8 New Features http://www.ggola.com

(controlfile내에 reusable section에 일정기간 RMAN이 필요로 하는 정보를 갖을 수 있다.)

- However recovery catalog없이 RMAN을 사용하는 것은 일정한 한계를 갖을 수 밖에 없다. 즉, tablespace poin-in-time recovery나 stored scripts를 사용한다거나, controlfile이 not current일 때 automatic recovery가 안된다.

- If the recovery catalog was in use and was destroyed, it can be partially reconstructed from the current controlfile or controlfile backup.CF. 문제가 생기는 control file의 자동복구가 가능하다.

- Catalog 사용하기 위한 순서1. 해당 user생성 (catalog 전용 tablespace를 생성하여 할당하자 – user별 export를 통해 catalog자체 backup이 유용해진다)2. recovery_catalog_owner role을 grant한다.3. catrman.sql을 생성한다.

Packages and Commands

Packages

- RMAN은 backup, recover, and restore를 위해 Packages를 사용한다.

- RMAN은 Packages를 사용하여 O/S에게 backup, restore, recover와 관련한 commands를 보내고 지침을 준다.

- 만일 third-party storage subsystem을 사용한다면 RMAN은 subsystem이 interpret and execute하도록 API를 통해 단지 command만을 보낸다.

Maintenance Commands

- register a database with recover catalog, all information을 targeted database에 pulling

- targeted database에 incomplete recovery가 수행되면 recovery catalog의 database information을 reset

- reset the database to point to information on previous backups of the targeted database

- targeted database의 changes를 반영하기 위해 recovery catalog update

- backup controlfile의 state를 반영하기 위해 recovery catalog update

[email protected] - 79 - 장 경상

Page 80: Oracle History #4

Oracle8 New Features http://www.ggola.com

Script

- RMAN operation은 script로 저장되거나 run command로 직접 수행할 수 있다. Run command를 사용하는 경우엔 모든 operation은 바로 수행될 것이다.

- Script는 RMAN operation에 빈번히 사용되는 것들을 지정하는 set of commands로서 ‘CREATE SCRIPT’ command로 만들어지며 recovery catalog에 저장된다. (물론, 이 script는 run command에서 call할 수 있다)CF. recovery catalog가 없는 때를 대비하여 이 script들을 O/S상에 copy해 놓는 것이 추천된다.

Report and List Commands

- Report commands1. redundancy or incremental requirement을 기반으로 하는 backup을 필요로 하는 files2. 수일동안 backup이 되지않은 files3. delete될 수 있는 backup files4. recover될 수 없는 files

- List commands1. backup sets that contain a backup of a specified datafiles2. copies of a specified list of datafiles3. backup sets that contain a backup of any datafile that is a member of a specified list of tablespaces4. copies of any datafile that is a member of a specified list of tablespaces

Backup Type

Backup Sets

- datafile backup set : datafile이나 controlfiles을 포함하는 backup set으로 archivelog files을 함께 backup set으로 묶을 수는 없다.

- Archivelog backup set : archived logs를 가지는 backup set

- Platform에 따라 지원되는 devices를 알기 위해서 V$BACKUP_DEVICE view를 참조할 수 있다.

- Backup set으로 묶이는 backup은 backup media로 바로 creation될 수도 있고 일단 disk에 만들어진 후 나중에 backup media로 copy될 수도 있다.

[email protected] - 80 - 장 경상

Page 81: Oracle History #4

Oracle8 New Features http://www.ggola.com

Image Copies

- 기존의 전통적 방식의 backup으로 이해하면 되겠다. Single단위의 file copy

Backup set

General Backup Set

- full and incremental backupsCF. archived logs and datafiles and controlfiles 모두 backup set으로 만들 수 있다.

- user-specified parameter를 이용하여 backup set에 concurrently backup되는 datafiles 수를 조정할 수 있다.CF. This concurrency is useful for keeping a tape device streaming without saturating a single datafile with too many read requests and thereby degrading online performance.

- Datafile backup set은 current datafiles로부터 만들어질 수도 있고 먼저 만들어진 datafiles copies로부터 만들어질 수도 있다.

- Backup set에서 file을 extracting하기 전에 restore operation을 먼저 수행해야 한다.

- Recovery하는 동안 RMAN은 tape or disk상의 backup set으로부터 archived log files or datafiles을 stage할 수 있다.

Multiplexed Backup Set

[email protected] - 81 - 장 경상

Datafile#1

Datafile#2

Datafile#n

.........

1차 2차 n차

Tape#1

Tape#2

Tape#n

Page 82: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 하나 이상의 datafiles or tablespaces를 지정하면 지정된 datafile들이 concurrently로 backup되어 multiplexed되도록 할 수 있다.

- A higher-performance sequential output device can be kept streaming by including a sufficient number of datafiles in the backup. 이것은 backup operation이 online system I/O bandwidth와 충돌이 있을 때 매우 중요한 요소이다.

- Multiplexed backup의 Oracle logical block size는 모두 동일하며 controlfile의 경우 가장 먼저 write되고 그 block은 multiplex되지 않는다.

- 만일 여러 datafile을 multiplexed backup set으로 구성하면 첫번째 backup set과 그 후에 일어나는 backup set들은 한 backup media에 저장될 수 없으므로 backup set 수만큼 backup media에 즉, backup media가 tape이라면 그 만큼의 tape에 spawn되어야 한다.

- RMAN이 지정하는 blocks number만큼씩 첫번째 datafile부터 마지막 datafile까지 block read/write를 진행하여 backup set을 만들고 다시 첫번째 datafile부터 마지막 datafile까지 … 반복적으로 backup set을 만든다.

단, tape이나 backup media가 장착된 targeted database에 media change(예를 들면 tape교체 등)는 operator나 storage subsystem이 담당해야 한다.

Backup piece

- Backup piece란 한 backup set의 single output file이다. 즉, piece수 만큼 output files 개수가 결정된다.

[email protected] - 82 - 장 경상

Datafile#n

Backup Set

Tape#1 Tape#2 Tape#n

Datafile#2

Datafile#1

Datafile#n

Datafile#2

Datafile#1

Datafile#n

Datafile#2

Datafile#1

Backup piece Backup piece Backup piece

Page 83: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Backup piece는 file on file system이지만 tape volume처럼 하나의 physical entity로 표현되는데 PL/SQL procedure call로 a single sequential file을 만든다.

- A backup set is a complete set of backup pieces that constitute a full or incremental backup of the objects specified in the backup set.

Image Copies

- 일반 file copy와 동일함으로 특별한 restore operation을 요구하지는 않지만 RMAN의 Image Copies는 오직 disk로만 write될 수 있다.

- Contains only a single input file (datafile, archivelog, controlfile)

Full and Incremental

Datafile backup

- datafile은 크게 full backup과 incremental backup으로 나뉘어 진다. Full backup은 datafile의 모든 block을 갖는 하나 이상의 datafiles backup이고 incremental backup은 previous backup이후에 modified된 block만을 갖는 하나 이상의 datafiles backup이다.

- Oracle provides an option to make cumulative incremental backups at any particular level. These backups reduce the work needed for a restore operation by ensuring that you need only one incremental backup from any particular level at restore time. However, cumulative backups require more space and time because they duplicate the work done by previous backups at the same level.

- An option is provided to allow the creation of a full backup that is ignored by subsequent incremental backups.(즉, subsequent incremental backups이 full backup이 없었던 것처럼 인식하도록 하는 option이 제공된다)

Multilevel incremental backup

- multilevel incremental backup features를 통해서 incremental backup의 different levels을 만들 수 있다.

- Multilevel incremental backups은 restore시 특정 level에서의 one incremental backup만을 필요로 하므로 recovery operation을 용이하게 해준다.

[email protected] - 83 - 장 경상

Page 84: Oracle History #4

Oracle8 New Features http://www.ggola.com

- 8가지 level을 지원할 수 있으며 숫자로 표시되고 0은 항상 full backup을 의미한다. Default로 incremental backup은 마지막 backup이후의 변경된 blocks으로 구성된다.

- 예를 들면 0은 full backup, 1은 월 단위, 2는 주단위, 3은 일 단위 등으로 설정하여 incremental backup을 할 수 있다.

Others

User-created backups

- backup types created using some mechanism other than recovery manager. (like image copies)

- You must catalog the OS copies with recover manager before they can be used in a restore or switch operation.

- Support cold and hot backups (offline and online user-created copies)

Tags

- Tag란 backup set이나 file copies에 대하여 assign하는 logical name이다. 이 이름을 사용함으로써 backup set이나 file copies를 유용하게 참조할 수 있다.CF. tag는 최대 30 characters까지 가능하다.

- RESTORE or SWITCH command를 사용할 때 tag를 지정하면 RMAN이 tag에 matching되는 backup set을 선택할 것이다.

- Multiple backup sets에서 Tag는 여러 backup set이나 file copies에 대하여 동일한 tag를 가질 수 있으므로 이러한 경우 주어진 datafile에 대하여 가장 current suitable file을 참조한다.

Parallel Operations

- Backup, restore, and recovery operation은 RMAN에 의해 parallel로 수행될 수 있다.

- RMAN은 serially로 command를 수행함으로 next command가 시작되기 이전에 previous command가 종료되어야 한다.Parallelism is exploited only within the context of a single command.

[email protected] - 84 - 장 경상

Page 85: Oracle History #4

Oracle8 New Features http://www.ggola.com

Tablespace Point-in-Time Recovery

- Oracle8 recovery feature는 system tablespace를 제외한 나머지 모든 tablespace에 대하여 recovery catalog를 이용하여 point-in-time recovery를 지원한다.

- 이 작업을 하기위해선 사전에 oracle instance suitable for mounting and recovering the clone database를 준비해야 하고 다음과 같은 네가지 요소를 필요로 한다.1. two small redo logs separate from the redo logs of the original database.2. one controlfile separate from the original database3. user/pwd for access the clone database with SYSDBA or SYSOPER4. connect string to the clone database instance

Operational Constraints and Checking

- Backup은 database mount or open mode에서 수행된다.

- Restore는 instance가 start되어 있으면 가능하다. 즉, controlfile이 유실되었을 때 유용할 수 있다. (restore는 nomount상태에서도 진행할 수 있다)

- Oracle8은 automatic integrity checking뿐만 아니라 unusable backup files or corrupt restored datafiles을 감지하여 이에 대한 operation을 못하게 한다.

- Backup동안 감지된 corrupt datafile blocks은 controlfile과 alert.log에 기록된다.

- 또한 Fractured block을 감지하여 적절한 조치를 취하게 된다. Fractured block은 그 block이 written되는 동안 backup utility에 의해 read된 block이므로 필연적으로 inconsistent할 수밖에 없다. 따라서 Oracle8은 Checksum으로 하여금 backup utility가 the fractured block을 감지하여 consistent version을 갖을 수 있도록 다시 read하게 한다.

CONTROL_FILE_RECORD_KEEP_TIME

- 이 parameter는 control내에 reusable record sections에 대한 보존기간을 설정한다. Control file의 어떤 sections에는 RMAN에 의해 사용된 정보를 갖고 있는데 이를 특정기간동안 보존하기위한 initial parameter이다. (즉, recovery catalog를 사용하지않는 경우 유용하다.)

- 이 parameter는 일단위로 지정함으로 만일 0으로 setting하면 항상 reusable한 상태가 되고 특정 숫자를 지정하면 그 해당 날짜만큼 그 sections을 보존 시킨다. 따라서 지정일 이전에 sections이 다차면 이 record section이 늘어난다.

[email protected] - 85 - 장 경상

Page 86: Oracle History #4

Oracle8 New Features http://www.ggola.com

Data Dictionary Views

- controlfile로부터 필요로 하는 정보를 참조할 수 있다.

- V$ARCHIVED_LOG, V$BACKUP_CORRUPTION,V$BACKUP_DATAFILE, V$BACKUP_REDOLOG,V$BACKUP_SET, V$BACKUP_PIECE,V$BACKUP_MEMBER, V$BACKUP_RESTORE_STAT,V$BACKUP_PARMS, V$DATAFILE

[email protected] - 86 - 장 경상

Page 87: Oracle History #4

Oracle8 New Features http://www.ggola.com

11. Advanced RMAN

Catalog Commands and Reports

Catalog Command

$RMAN target \“user/password@db_link\” rcvcat \“user/password@db_link\” cmdfile \“/u01a/oracle/rman/back.sql\” mslog \“/u01a/oracle/rman/rmsg.log\” append

- TARGET : target database

- RCVCAT : recovery catalog database

- CMDFILE : batch mode로 지정한 file의 내용을 수행

- MSGLOG : log가 생기면 지정된 위치에 저장. 만일 지정되지 않으면 standard output처리

- APPEND : log write시 위 msglog file이 있으면 append로

Error Handling

- RMAN은 error가 나타나면 처리를 중단한다. RMAN은 다음 3가지중 하나를 return하고 log file에 남긴다.

1. EX_SUCC : All commands were successfully processed.

2. EX_FAIL : No commands were successfully processed.

3. EX_WARN : At least one command successful, but resulted in an error.

Catalog Maintenance Operations

- rman> register database ;RMAN이 관리할 database 등록

- rman> reset database ;incomplete recovery가 되면 resetlogs option을 사용 DB open

- rman> resync catalog ;controlfile에 영향을 주는 구조적 변화나, rollback segment add or drop시 실행하여 recovery catalog를 다시 맞춘다.

[email protected] - 87 - 장 경상

Page 88: Oracle History #4

Oracle8 New Features http://www.ggola.com

- rman> allocate channel for delete type disk ;rman> change datafilecopy ‘/…ora/….dbf’ delete ;rman> release channel ; allocate a channel to establish the connection to a target database instance. change command는 backup piece, datafile copy, archivelog를 대상으로 하여 unavailable, available mark하거나 delete(OS file delete) 또는 removes references to a backup piece, datafile copy, or archivelog

- rman> catalog datafilecopy(archivelog, backuppiece, backup controlfile qstring) “/u01/oracle/…./..back_data2.back” ;add information to the recovery catalog use the catalog command with both the datafile and archivelog option. 한번에 하나의 file을 대상으로 적용된다) this command는 RMAN Install이전에 만들어진 files and RMAN이 아닌 다른 방식으로 만들어진 file copies에 대한 information을 catalog에 add할 때 유용하다.

Report Command

- Which database files need to be backup up ?Which files haven’t been backup up in a while ?Which backup files can I delete ?Which files can’t be recovered ?

- rman> report need backup incremental 3;DB crash시 incremental 3개 이상 필요한 backup data는 ?

- rman> report need backup days 3;최근 3일 동안 backup 받지 못한 것은 ?

CF. need backup redundancy integer deletable (redundancy integer) unrecoverable

List Command

- backup sets that contain a backup of any archivelogs with a specified name and/or within a specified range

- copies of any archivelog with a specified name and/or within a specified range

- incarnations of a specified database

- rman> list copy of tablespace ‘USERS’ ;image copy 형태의 backup본 정보 list

[email protected] - 88 - 장 경상

Page 89: Oracle History #4

Oracle8 New Features http://www.ggola.com

- rman> list backups of datafile “/u01/oracle/…../user01.dbf” ;backup set 방식의 backup본 정보 list

- rman> list incarnation of database “ORA*SE” ;현재 incarnation 정보 list

CF. copy of (datafile qstring/integer) backupset of (tablespace qstring/integer)

RUN Commands and Scripts

RUN Commands

- used for backup, restore, copy, recover, and channel control commands

- legal only in the ‘curly brace’ section of a run command

- compile the commands in the command_list

- run {execute script script_name;}; 만들어진 scripts file실행

- rman> create script back_full { allocate channel t1 name “tape_c1” ; backup full tablespace 2 (database format “v8db1.full.%s.%p”); release channel t1 ; } ;rman> run {execute script back_full ; } ;

CF. run { allocate channel channel_list release channel id setlimit channel id setlimit_list execute script qstring backup backup_list copy imputfile to outputfile copy_list switch datafile datafile_list restore restore_list recover recover_list sql DCL_list }

- allocate channel command : allocate command를 연속적으로 사용함으로써 multiple channel을 설정할 수 있고 각 channel은 separate connection을 사용하여 작업을 하게 된다. 반드시 1개 이상의 channel이 필요한 command는 backup, copy, restore, or recover이고 작업 이후 channel resource를 해제하기 위해 release channel command를 사용한다.CF. copy는 not backup set. 즉, only disk만 해당

[email protected] - 89 - 장 경상

Page 90: Oracle History #4

Oracle8 New Features http://www.ggola.com

CF. channel에 대한 설정을 위해 setlimit을 사용할 수 있다.CF. channel수 만큼 parallelism이 결정된다.

- setting attributes :run{ set maxcorrupt integer/newname qstring/archivelog destination qstring } attribute description : block corruption check하여 지정한 수에 이르면 terminate backup or copy command/ restore and switch command for datafile의 default name setting/ archive dest에 disk crash가 발생하면 archive dest를 override(바꾸어준다)

Backup Command

- backup을 수행하기 위해 backup command로 하나 이상의 backup sets을 만든다.

- Backup sets은 datafile을 across로 split하여 만들 수 있지만(Multiplexed) Files cannot be split across backup sets.

- Datafile and controlfile은 하나의 backup set으로 구성될 수 있지만, archive와 datafile은 하나의 backup set이 될 수 없다.. (block format이 다르므로)

- Run { backup full/incremental level integertag tagcumulativenochecksumfilesperset integermaxcorrupt integerparms qstringskip offlineskip readonlyskip inaccessibledatabase/tablespace/datafile/datafilecopy/archivelog/backup controlfile/current controlfile/backupset key (qstring id parms qstring filesperset integer delete input include current controlfile channel id tag qstring format (%v/%p/%s/%n) ) }

[email protected] - 90 - 장 경상

Page 91: Oracle History #4

Oracle8 New Features http://www.ggola.com

Copy Command

- Copy command로 file copy (only written to disk)can be input files of the following current datafile, datafile copy created by 이전 copy or 다른 방식의 copy archivelog current controlfile backup controlfile

- Run { copy datafile qstring datafilecopy qstring datafilecopy tag qstring archivelog qstring controlfile qstring controlfile tag qstring current controlfile to qstring/tag qstring/level 0 }

Switching Datafiles

- to convert a datafile copy into a current datafileCF. The filename of the datafile copy becomes the new filename of the datafile as listed in the controlfile.

- Media recovery is required for the datafile.

- Use this command when you want a datafile copy to become the current version of a datafile

- rman> run { switch-datafile qstring to/all datafilecopy tag qstring }

Restore Command

- restore full datafile backup sets(level 0) or datafile copies

- restore command를 수행하기 위해선 target database instance는 반드시 start되어 있어야 한다.

- If the entire database is to be restored, then it must be closed.

- At least one channel allocate command must precede the restore command

- rman> run { restore from backupset/datafilecopy until time/scn/logseq thread (불완전 restore시 restore limit정하기 tag tage channel channel_id controlfile from_tag to_specifier database skip_clause

[email protected] - 91 - 장 경상

Page 92: Oracle History #4

Oracle8 New Features http://www.ggola.com

datafile restore_datafile_list tablespace restore-tablespace_list archivelog archivelog_specifier )

Recovery Command

- recover database/tablespace/datafile

- rman> run { recover database until time/scn/logseq thread tablespace qstring datafile qstring }

Stored Scripts

- recovery catalog를 사용하는 경우에만 가능한 scripts

- a stored scripts is a named sequence of Recovery Manager commands.

- Allows planning, developing, and testing of scripts

- Command : create script qstring commad_lsit ; replace script qstring command_list ; delete script qstring ; print script qstring ;

[email protected] - 92 - 장 경상

Page 93: Oracle History #4

Oracle8 New Features http://www.ggola.com

12. Enhancements to Networking

Enhanced Features

Scalability

Scalability challenges involve high-end online transaction procession(OLTP), data warehousing, and messaging driving for highly scalable servers.

- Multiplexing

- Connection pooling

- Concentration

- Naming Services<service naming resolution method>1. local naming : tnsnames.ora 사용2. names server 방식 : name server를 한 machine에서 관리 (tnsnames.ora 사용안함)3. host naming 방식 : host이름만 기술하여 사용할 수 있도록 한 것으로 protocol, port, sid등을 option으로 지정하여 사용 (tcp, 1521, sid 1개등의 형식으로 지정 : usr/pwd@hostname 형태로 사용하며, tnsnames.ora는 사용하지 않음)

Connectivity

- support for foreign data sources RDB and Express

- Enhanced ODBC connectivity-“Classic” ODBC driver(This driver has support for stored procedures.)

Security

Security를 제공하지 않는 Net8을 위해 별도 feature인 Oracle Security Server를 통해 Security문제를 해결할 수 있다.

- Single sign on

- Private/Public key authentication

- Support for third party security servers(third party를 위한 adapter제공)

- Works with Oracle Advanced Networking Option

[email protected] - 93 - 장 경상

Page 94: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Digital signatures

Performance

- TNS Raw

- Names information cached on client sid(Names Server내용을 cache)

- Optimize dispatcher code path

Ease of configuration and administration

점점 방대해지고 복잡해지는 network service를 보다 편리하게 setting할 수 있도록 Tool제공

- Enterprise manager support as well as separate applets

- Centralized and local configuration options

- Oracle Names enhanced dynamic discovery

- Client profiles

- Configuration wizard (Net8 wizard)

- Default configuration supplied for small-scale systems

Connection

Connection manager

Connection manager는 MTS상에서만 유효한 new standalone application으로 many heavy or continuous client applications에 유용하다.

- access control : firewall처럼 checking whether a party is authorized to transmit across it. (특정 IP제어도 가능하다.)

- cross protocol : Multiple Interchange기능 즉, passing data from one protocol to another.

- Multiplexing : accepting data from multiple separate connections and multiplexing the data into one common physical transport.

Multiplexing (based on MTS only)

- Multiple logical sessions across a single physical transport.

- Scalability for XA links and server-server links.

[email protected] - 94 - 장 경상

Page 95: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Initial connection requests가 a single physical transport를 만들고 이 후의 connections requests들은 이미 만들어진 transport에 생성된다CF. transport connection은 모든 logical sessions이 closed된 후에 closed된다..CF. However if a different process requests a connection, then a new physical transport is created

- Multiplexing allows thousands of clients to access the server simultaneously without performance degradation.CF. allows additional sessions to access the server above what would be allowed by operating-system limits.

Connection Pooling

conn = 3 : 항상 작업 가능한 session 수sess = 5 : session이 맺어질 수 있는 max session 수

- A connection pool is the maximum allowed number of connecting that is shared among several clients. Connection pooling removes the burden of maintaining unused connections, thereby improving the performance of active sessions.

- Connection pooling은 idle한 connection을 check하여 temporarily disable하고 작업하려는 session을 incoming connection으로 조정한다. 즉, disabled connection이 작업이 필요하게 되면 다른 idle session을 disable시키고 disabled connection이 활성화 된다. 따라서 가능한 한 많은 수의 connection을 유지할 수 있도록 한다.

- Connection pooling allows an incoming connection to be established with the database even if the maximum number of connections specified by the administrators has been reached.

Increases the number of client-server sessions possible across a fixed number of physical server ports.

Ideal for “high think/search time apps” such as email and warehousing.

[email protected] - 95 - 장 경상

Page 96: Oracle History #4

Oracle8 New Features http://www.ggola.com

Listener Enhancements

Listener enhancements for N-tier support, multithreading generic servers.

Two-tier Configuration

1. Typified by the use of synchronous RPC over a connected transport protocol, such as TCP/IP.

2. Client calls a function on a remote server and is suspended until it gets back the results

3. Server must be active else the “function call” fails

4. Interaction takes place over a dedicated network connection-if the function is time-consuming, that means poor utilization of network resources.

N-tier Configuration

1. The use of Net8 transport is asynchronous and operates over a disconnected transport service, such as a distributed message queue

2. Client places its function request on a remote message queue and terminates

3. When active, the server, for that queue reads the message, executes the function, and calls back the client. Then the whole process is reversed.

4. This configuration is generally not favored when fast response times are critical, but it is attractive when considerations such as scaling and load balancing are paramount or when topographical constraints preclude the connected approach.

TNS Raw

- data moving시 부가되는 Layer측면의 data를 없앰으로써 보다 가볍게 data를 이동시킨다.

- The Raw Transport feature improves connection performance in two ways1. Without Net8 headers, less data is transmitted over the network.2. By making low-level protocol API calls, a couple of Net8 protocol layers are bypassed. Therefore, less processing is performed against the data, which translates to less time used in processing the client request.

[email protected] - 96 - 장 경상

Page 97: Oracle History #4

Oracle8 New Features http://www.ggola.com

Network Security

Extended Security Services

Advanced Networking option을 통해 Net8로 하여금 network data encryption and checksumming을 가능케 함으로써 data가 read and altered 되지 않도록 할 수 있다.

- this option은 RSA, DES, MD5등 몇 개의 encryption algorithm을 사용할 수 있도록 adapter를 지원한다.CF. Connection Manager는 this option을 통해 different protocol을 사용하는 clients and servers간에 안정적으로 data를 transfer할 수 있다.

- External security servers can be used to authenticate users and set up their credentials. (별도의 security server 운영가능)

Oracle Security Server

Oracle Security Server는 별도로 구입(?)해야 하는 feature이므로 개략적 설명으로 대체

- The Oracle Security Server allows you to assign attributes(roles) to a principal(Database, Oracle Webservers, users, and so on).CF. An application uses the attributes of the principal to determine whether the principal can access its objects.

- Distributed stored procedures can be accessed on remote servers if the global role allows it. In Oralce7 these procedures were accessed by hardcoding a username and password into the application.

- Single sign-on in Oracle environment public/private key-based user authentication

- Digital signature verified origin Users standards-based X.509 digital certificates Oracle Security Services API provided for applications

- Secure distributed computing Mutual authentication (not one-way) precludes existence of rogue databases and provides secure database links

[email protected] - 97 - 장 경상

Page 98: Oracle History #4

Oracle8 New Features http://www.ggola.com

Advanced Functions of Net8

Improved Naming Services

Oracle Names is a directory service that provides name-to-address resolution for each Net8 service on the network. Oracle Names with Net8 has three features to improve network performance and ease of administration.

1. Dynamic service resolution Net8 services can register themselves with a Names Server

2. Client discovery of Names Servers The client can retrieve a list of Names Servers at installation

3. Names resolution optimization (client-side cache) The client maintains a list of names Servers and name query results in a local cache.

Once every component is registered and running, the client can find any service on the network by following these steps.

1. The client provides the service name.

2. The service name is forwarded to each Names Server on the list until it is resolved to a destination address. The list of names Servers is stored in the .SDNS.ORA file.

3. whit the resolved destination address, the client initiates a session request to the database server.

Oracle Names in Net8 does not require a database to hold topology information. However, database storage is recommended.

Simplified Management

There are two types of server networks that need to be configured.

- Work group : has a client that connects only one server. 이 경우 별다른 configuration이 필요하지 않고 default를 사용하나 굳이 default를 사용하지 않는다면 configuration이 필요하다.

- Enterprise Server : has clients that may connect to several servers. 즉, 다양한 형태의 configuration이 있을 수 있다. Net8 does not use the Network Manager to create

[email protected] - 98 - 장 경상

Page 99: Oracle History #4

Oracle8 New Features http://www.ggola.com

configuration files. The Network Manager functions are now applets to be used either with the Oracle Enterprise Manager or as standalone applets.

Client Administration

New configuration options

1. Configuration-free installation option

2. Centralized client administration

3. Automated client configuration

- Net8 automatically configures itself on TCP/IP networks 한다. 만일 optional features가 없는 simple network이라면 전혀 configuration할 필요가 없다. The client and the services find a well-known Names server and then receive information about any other Names Servers in the network. The client can find any service on the network by contacting the list of Names Servers.

- Multithread servers는 스스로 listeners를 가지고 register하므로 all defaults로 생성되면 이들 listeners는 LISTENER.ORA file이 필요 없다.

- For a Names Server environment, you define client profiles with the Client Profile Editor. The Net8 client automatically loads client profile data from the Oracle Names server at startup

Net8 Wizard

This automates initial client configuration.

- is invoked during installation

- locates and orders Names Servers.

- reads list of client profiles from the Name Server prompting the user for a specific or default profile

- profile이 없으면 Net8에서 제공하는 defaults를 사용한다.

- Configuration files를 editing할 수 있다.

Native Hostname Adapter

Oracle Names Server를 사용하지 않는 환경에서 local naming system(DNS or NIS)을 사용하여 user에 의해 request된 hostname을 가지고 IP address를 return하여 connect한다.

[email protected] - 99 - 장 경상

Page 100: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Procedure1. client : scott/[email protected]. DNS : hanjin.com의 IP return to client3. Net8 : forward connect request to the listener on the host

Hostname adapter를 사용하려면 다음과 같은 조건이 충족되어야 한다.

- TCP/IP 사용

- Net8 listener is serving only one database

- All names are resolved through the operating system’s naming system, DNS or NIS

- Listener redirects the connect request to the single database it is servicing.

- No security services are requested

Tracing

Net8이 Oracle Trace를 사용하면서 얻는 이점은 다음과 같다.

- Smaller executable size because the tracing facility is external to Net8.

- Ability to trace complete client sessions from the client through to the server.

New Trace Assistant Tool을 사용할 수 있다.

- Extracts error messages and displays text in a file

- Extracts packet type and information sent to or received from the client or the server.

- Tracks statistics of packets.

Net8 Open API

Net8 OPEN 이라 불리는 API(application program interface)를 사용한다.

- any platform, any protocol을 support한다.

- Net8 OPEN provides applications a single common interface to all industry-standard network protocols.따라서, system이 바뀌더라도 network calls은 modification 없이 사용할 수 있다.

[email protected] - 100 - 장 경상

Page 101: Oracle History #4

Oracle8 New Features http://www.ggola.com

[email protected] - 101 - 장 경상

Page 102: Oracle History #4

Oracle8 New Features http://www.ggola.com

13. Implementing Password Management

Management

Enabling password

- run script by user ‘SYS’ $ORACLE_HOME/rdbms/admin/utlpwdmg.sql

- 위 스크립트는 다음과 같이 default profile setting and password verification routine을 제공하며 나중에 바뀌어질 수 있다.ALTER PROFILE DEFAULT LIMITPASSWORD_LIFE_TIME 60PASSWORD_GRACE_TIME 10PASSWORD_REUSE_TIME 1800PASSWORD_REUSE_MAX UNLIMITEDFAILED_LOGIN_ATTEMPTS 3PASSWORD_LOCK_TIME 1/1440PASSWORD_VERIFY_FUNCTION verify_function ;

- You can lock, unlock, and expire accounts using Create user and Alter user syntax.

- init.ora or alter session으로 수정될 수 있는 Database or Session을 위한 RESOURCE_LIMIT parameter가 FALSE로 setting되더라도 password limits는 항상 enforced되어 있다.

Account locking

Server는 login 실패 시도횟수를 check하여 지정된 횟수만큼 실패할 경우 자동으로 lock을 잡는다.

- 이 규약은 group단위 혹은 user단위로 적용할 수 있다.

- 이 lock은 setting된 configuration에 따라 일정시간이 지난 후에 또는 system security officer에 의해 manually unlock된다.

- Security officer에 의해 explicitly lock이 가능하며 이러한 lock의 경우 반드시 security officer에 의해서만 unlock이 가능해 진다.

Password aging and expiration

Password에 expiration을 설정하고 grace period를 줄 수 있다.

[email protected] - 102 - 장 경상

Page 103: Oracle History #4

Oracle8 New Features http://www.ggola.com

- password는 변경된 이후 Create profile 문을 사용하여 group 단위 혹은 user단위로 maximum lifetime을 갖을 수 잇다.

- Password expiration시점 이후의 첫번째 login부터 grace period를 설정할 수 있다. 이 grace period동안 매번 login시마다 경고 message를 보내며 grace period가 지날 때 까지 password변경이 없으면 lock을 걸고 그 account로는 더 이상 login을 허락하지 않는다.

- 물론, explicitly password expiration이 가능하며 이때는 바로 grace period가 적용된다. Explicitly password expiration은 일반적으로 new account가 생길 때 유용하게 사용된다.

Password history

Password를 변경할 때 과거의 password를 참조하여 특정 기간동안에는 예전에 사용된 password는 사용할 수 없도록 할 수 있다. (using Create profile statement)

Password complexity verification

Password를 변경할 때 ‘SYS’소유의 PL/SQL function 혹은 ‘SYS’소유로 만들어질 PL/SQL function을 통하여 new password에 규칙을 적용할 수 있다. 즉, new password에 복잡한 수준의 정도를 요구할 수 있다.

- alpha, numeric, and punctuation marks, and so on등의 규칙을 정할 수 있다. (using Create profile statement)

- default password verification routine1. a minimum length of 4 characters2. not be equal to userid3. at least one alpha, one numeric, and one punctuation mark4. differ from the previous password by at least 3 letters

- password function format은 반드시 다음의 형식을 따른다.

이 function은 raise exception error나 invalid가 되면 적절한 error message를 return하고 terminated된다. 이 function은 ‘SYS’소유이고 ‘SYSTEM’ context에서 실행된다.

[email protected] - 103 - 장 경상

function_name (userid_parameter in varchar2(30),password_parameter in varchar2(30),old_password_parameter in varchar2(30) )

return boolean

Page 104: Oracle History #4

Oracle8 New Features http://www.ggola.com

- password verify function은 다음과 같이 설정된다.CREATE/ALTER PROFILE profile_name LIMITPASSWORD_VERIFY_FUNCTIION funcion_name ;

Command and Data Dictionary

Create profile command

Create/Alter profile prof_name LIMITFAILED_LOGIN_ATTEMPTS (시도 회수)PASSWORD_LIFE_TIME (number of days)PASSWORD_REUSE_TIME (number of days)PASSWORD_REUSE_MAX (password 재사용 최대가능 회수)PASSWORD_LOCK_TIME (number of days)PASSWORD_GRACE_TIME (number of days) integer/unlimited/defaultPASSWORD_VERIFY_FUNCTION func_name/unlimited/default

- PASSWORD_REUSE_TIME and PASSWORD_REUSE_MAX는 둘 중 하나가 default or unlimited가 아니면 다른 하나는 반드시 unlimited이어야 한다. (둘 중 하나만 사용할 수도 있다)

- PASSWORD_LOCK_TIME을 unlimited로 설정하면 lock된 password는 forever lock이 되고 security officer만이 unlock해 줄 수 있다.

Create user command

Create/Alter user username identified by ???/externallydefault tablespace tbs_nametemporary tablespace tbs_namePROFILE prof_nameQUOTA integer/unlimited on tbs_namePASSWORD EXPIREACCOUNT LOCK/UNLOCK ;

- 위 명령을 통해 만들어진 profile을 할당하고 password expire 및 account lock/unlock을 할 수 있다.

Data Dictionary

- Enhanced views인 USER_USERS, DBA_USERS에 column이 추가 되었다.ACCOUNT_STATUS : 현 계정이 lock, expire, or openGRACE_DATE : password가 언제 expire 될 것인가

[email protected] - 104 - 장 경상

Page 105: Oracle History #4

Oracle8 New Features http://www.ggola.com

LOCK_DATE : 현 계정이 언제 lock되었는가.EXPIRY_DATE : 현 계정의 expiration date가 언제인가.CF. GRACE_DATE는 8i에서 없어짐.

- DBA_PROFILES view enhanced “RESOURCE_TYPE”profile이 KERNEL인가 PASSWORD parameter인가

- USER_PASSWORD_LIMITS view is created newly.lists the password resource limits for that userRESOURCE_NAME : name of password resourceLIMIT : limit as assigned to the user (profile이 default이면 default profile limit이 display된다)

[email protected] - 105 - 장 경상

Page 106: Oracle History #4

Oracle8 New Features http://www.ggola.com

14. Migration Server and Applications

What is migrated from 7 to 8 ?

Oracle8의 many new features를 사용하기 위해선 data dictionary를 비롯하여 여러 변경이 필요한 부분들이 있다.

Changes

- new tables이 add되고 Oracle8의 new information을 추가하기 위해 기존 old tables에 수정이 필요하다.

- Views와 v$tables(dynamic performance tables)에 related information이 update된다.

- Datafile header block, controlfile, redo log files의 구조에 추가적인 수정이 필요하다.

The new dictionary structure and file structures must be in place for Oracle8 to work with the database. The migration process ensures that this occurs.

Migration Roles

Migration을 하기 위해선 관련된 사람들의 역할이 분명해야 한다.

- Database Administrator1. 관련된 모든 사람들을 만나서 각자의 역할부여 및 확인2. Oracle7 즉, current version database backup3. migration 진행4. Oracle8 즉, upgrade된 database backup

- Application Developer1. Oracle7 and 8 즉, upgrade에 따른 변경사항 인식.2. Check for Data dictionary and Dynamic performance table3. migration 이전 과 이후의 applications validation확인을 위해 test suite 준비

- Usersmigration이전과 동일한 작업을 할 수 있는지 functionality 측면에서 확인

[email protected] - 106 - 장 경상

Page 107: Oracle History #4

Oracle8 New Features http://www.ggola.com

Migration Steps

1. Prepare to migrate

2. Secure the required resources

3. Build a test plan

4. Preserver the source database (backup)

5. Migrate the source database

6. Make any necessary adjustments

Migration Steps

Step1 : prepare to migrate

- database migration으로 인해 발생할 영향 및 new features의 내용에 대한 각 관련 부문별 인식공유

- migration method 결정1. migration utility2. export/import3. copying data

- Migration을 지원할 수 있는 충분한 system resources가 확보되었는가.

- 잠재적인 문제 요소 확인1. Newly reserved word를 사용한 object name등은 없는가.2. 더 이상 불필요한(obsolete) parameter는 없는가.3. Data dictionary tables and views를 reference하는 scripts는 없는가.

Step2 : Secure the required resources

- operating-system-specific Oracle8 documentation을 참조하여 platform에 따라 Oracle7의 약 3배정도의 disk space 와 일반적으로 최소 16M RAM, realistic production systems을 위해선 최소 32M RAM 이 확보되어야 한다.

- Migration method에 따라 크기는 다르지만 migration을 진행하는 동안 추가적인 space가 필요할 것이다.

- Migration utility : system tablespace에 Oracle7 and Oracle8 모두의 data dictionary가 공존할 space가 필요하며 충분한 space를 확인하기 위해 Oracle7 database에 Migration utility의 CHECK_ONLY option을 사용한다.

[email protected] - 107 - 장 경상

왜 3배의 space가 필요한지명확하지 않다 .

Page 108: Oracle History #4

Oracle8 New Features http://www.ggola.com

- Export/Import : export dump file을 보존할 temporary space가 필요하다.CF. export files의 size추측은 Oracle8 Administrator’s Guide를 참조하라.

- Copying Tables : target database는 source database와 동일한 disk space를 필요로 한다.

Step3 : Build a test plan

- Migration test : migration method에 따라 test를 진행한다. 만일, migration utility를 사용한다면 일부분에 대한 test를 진행하기 위해 그 일부분만을 가지는 test database를 만들어야 할 것이다.

- Minimal test : Oracle8이나 new features없이 target database에서 application을 실행시키는 test를 진행한다. 물론 이때 발견되는 문제들이 production에서 발생한 모든 문제를 보여주는 것은 아니다.

- Function test : 새로운 환경에서 function이 이상이 없는가를 확인하기 위해 RDBMS, network, and application의 all components를 test한다.

- Integration test : test the integration of all the components(such as precompiled programs, tools..)

- Performance test : examine the performance of each SQL statement

- Volume/load stress test : 가상의 user load로 system에 부담을 주고 load의 정도를 test하여 data accessible and database performance acceptable을 확인한다.

Step4 : Preserver the Source Database

- 정상적인 full backup을 받기 위해 all datafiles and tablespaces online status 확인, active redo or outstanding transaction확인(incomplete distributed transactions등)하여 commit or rollback으로 종료, deferred rollback segment확인하여 tablespace online으로 eliminate deferred undo

- shutdown and restart : no active transaction 확인

- shutdown normal : all deferred rollback should be done

- database backup : datafiles, control files, online redo log files

- parameter files, 필요한 환경변수, 필요한 scripts등 backup

[email protected] - 108 - 장 경상

실 제 로 는 Utilities 를 참조해야 함

Page 109: Oracle History #4

Oracle8 New Features http://www.ggola.com

Step5 : Migrate the Source Database

- 더 이상 사용하지 않는 불필요한 parameters를 없애거나 수정하기

- 선택된 migration method에 따라 migration 진행

Step6 : Postmigration tasks

Following the migration, new version Oracle8에 대한 backup

- shutdown normal Oracle8

- cold backup full Oracle8 database

- 관리상에 필요한 scripts upgrade

- tnsnames.ora or new database link등 connectivity와 관련한 변경작업 진행

- migrate Oracle7 applications

Migration Method

Migration utility

- Oracle이 제공하는 사용이 용이한 tool로 requires minimal overhead and intervention.

- It rebuilds the source database in place.

- system tablespace에서 data dictionary를 rebuilding하여 entire database migration 하고 datafile header blocks 구조를 update한다.

- 장점. automatic, DBA intervention이 거의 없다, fast regardless of database size, requires relatively little additional disk space단점. can only migrate, cannot perform release-to-release upgrades

1. install migration utility and prepare the environment Run ORAINST (choose O7 O8) The utility is loaded into the Oracle7 ORACLE_HOME. installs : $ORACLE_HOME/bin – migration utility $ORACLE_HOME/dbs – migrate.bsq file new message file, required NLS files

[email protected] - 109 - 장 경상

Page 110: Oracle History #4

Oracle8 New Features http://www.ggola.com

2. run the migration utility : migration utility에 필요한 parameters 정의 CFILE : control file name (if not default) CHECK_ONLY : 필요한 space확인 CNVFILE : nondefault CONVERT.ORA filename DBNAME : migrate하려는 database name MIGFILE : migrate.bsq (if not default) NEW_DBNAME : migrated database의 new name MULTIPLIER : seg$/uet$ cluster index size increase factorNO_SPACE_TIMECHECK : no space and time checking before migration PFILE : parameter file (if no defatult) SPOOL : output spool file name

3. install Oracle8 softwareuse Oracle8 installer and select the install/upgrade option

4. prepare the Oracle8 database remove Oracle7 control files all files이 correct directories에 존재하는지 확인 init.ora parameter 조정 such as transactions_per_rollback_segment=21 or 21 이하로 compatible=8.0.0.0.0 또는 No setting

5. convert database : start the server managerSVRMGRL> connect internalSVRMGRL> startup nomountSVRMGRL> alter database convert ;

6. complete the conversionSVRMGRL> alter database open resetlogs ;SVRMGRL> @$ORACLE_HOME/rdbms/admin/cat8000.sqlSVRMGRL> @$ORACLE_HOME/rdbms/admin/catalog.sqlSVRMGRL> @$ORACLE_HOME/rdbms/admin/catproc.sqlSVRMGRL> drop user migrate cascade ;(migrate user는 migration utility가 자동으로 만든다)

CF. additional features를 사용한다면 run appropriate scripts

Export/Imprt

- Import이전에 Oracle8 database가 만들어져 있어야 한다. (잠시라도 Oracle7과 Oracle8이 공존해야 한다.)

- 장점. can migrate specific parts of the database, forward and reverse migration, can perform data compacting simultaneously, database can be restructured with new or modified tablespaces단점. Very slow for large database, from hours to days, large amounts of disk space and/or offline storage.

[email protected] - 110 - 장 경상

Page 111: Oracle History #4

Oracle8 New Features http://www.ggola.com

Copying data

- copy table data from Oracle7 to Oracle8. Sqlplus copy command를 포함하여 create table…. As select, insert into … select from, 등 SQL*Plus or PL/SQL등에서 작업을 해야 하며 source database and target database가 모두 running이어야 한다. (Oracle7 and Oracle8 모두 running)

- You must also build the required database links and ensure that SQL*Net is available to support them.

- 장점. can migrate specific parts of the database, can be used for release-to-release migration, can perform datafile defragmentation and data compacting, database can be restructured with new or modified tablespaces단점. Very slow for large database, both database must be available simultaneously

[email protected] - 111 - 장 경상