๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
ORACLE/ADMIN

[Oracle] Tablespace ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค ์ด ์ •๋ฆฌ(์ข…๋ฅ˜, ์ƒ์„ฑ, ์‚ญ์ œ, ์กฐํšŒ, ๋ณ€๊ฒฝ)

by ๐ŸŒปโ™š 2020. 7. 14.

Oracle Tablespace

์ผ๋ฐ˜์ ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๋ฐฐ์šด๋‹ค๊ณ  ํ–ˆ์„๋•Œ SQL๋ฌธ์žฅ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋ถ€ํ„ฐ ๋ฐฐ์›๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒ, ์ˆ˜์ •, ์‚ญ์ œ ์ž‘์—…์„ ํ•˜๋ฉด์„œ ๋ฌธ๋“ค ์ด๋Ÿฐ ์ƒ๊ฐ์ด ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. "๋‚ด๊ฐ€ ์กฐํšŒํ•˜๋Š” ์ด ๋ฐ์ดํ„ฐ๋“ค์€ ๋„๋Œ€์ฒด ์–ด๋””์— ์ €์žฅ ๋˜์–ด ์žˆ๋Š”๊ฑฐ์ง€?" ๋ฐ์ดํ„ฐ๋ฅผ ์กฐ์ž‘ํ–ˆ์œผ๋‹ˆ ์–ด๋”˜๊ฐ€์—๋Š” ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์กด์žฌํ•ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์ธ์‹ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. Oracle์—์„œ๋Š” Data file ์ด๋ผ๋Š” ๋ฌผ๋ฆฌ์  ํŒŒ์ผ ํ˜•ํƒœ ์ €์žฅํ•˜๊ณ  ์ด๋Ÿฌํ•œ Data file์ด ํ•˜๋‚˜ ์ด์ƒ ๋ชจ์—ฌ์„œ Tablespace๋ผ๋Š” ๋…ผ๋ฆฌ์  ์ €์žฅ๊ณต๊ฐ„์„ ํ˜•์„ฑํ•ฉ๋‹ˆ๋‹ค.

 

Tablespace๋Š” ํ•˜๋‚˜์˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์•ˆ์— ๊ฐ€์žฅ ํฐ ๋…ผ๋ฆฌ์  ์ €์žฅ๊ณต๊ฐ„์œผ๋กœ ์—…๋ฌด์˜ ๋‹จ์œ„๋‚˜ ์‚ฌ์šฉ์šฉ๋„์— ๋”ฐ๋ผ ์—ฌ๋Ÿฌ๊ฐœ์˜ Tablespace๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ๊ด€๋ฆฌ๋˜๊ณ  Segment(์˜ค๋ธŒ์ ํŠธ)๋ผ๋Š” ๋…ผ๋ฆฌ์  ์ €์žฅ๊ณต๊ฐ„์˜ ์ง‘ํ•ฉ์ด๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

 

 

Tablespace ์ข…๋ฅ˜

 Tablespace์˜ ์ข…๋ฅ˜๋Š” ํฌ๊ฒŒ 3๊ฐ€์ง€๋กœ ๋‚˜๋‰˜๊ณ  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์„ฑ ์‹œ ๊ผญ ํ•„์š”ํ•œ Tablespace 4๊ฐœ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

Permanent Tablespace

์˜๊ตฌ ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋Š” ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ธ ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ•์ ์šฉ๋„๋กœ ์‚ฌ์šฉ๋˜๋Š” ๊ณต๊ฐ„์ž…๋‹ˆ๋‹ค. Undo์™€ Temporary์™€๋Š” ๋‹ค๋ฅด๊ฒŒ ๊ณ ์˜์ ์œผ๋กœ ์‚ญ์ œํ•˜์ง€ ์•Š๋Š”ํ•œ ์˜๊ตฌ์ ์œผ๋กœ ๋ณด์กด๋˜๋Š” ๊ฐ์ฒด๋“ค์„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ์šฉ๋„์ž…๋‹ˆ๋‹ค. USERS๋‚˜ EXAMPLES ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค์ฒ˜๋Ÿผ ์ž„์˜์˜ ์ด๋ฆ„์„ ์ง€์ •ํ•˜์—ฌ ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๊ณ  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๊ฐ€ ์šด์˜๋˜๊ธฐ ์œ„ํ•ด ๊ผญ ํ•„์š”ํ•œ SYSTEM๊ณผ SYSAUX ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

 

SYSTEM(ํ•„์ˆ˜ ์š”์†Œ)

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์šด์˜์— ํ•„์š”ํ•œ ๊ธฐ๋ณธ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š” Data Dictionary Table์ด ์ €์žฅ๋˜๋Š” ๊ณต๊ฐ„์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ Tablespace ์ž…๋‹ˆ๋‹ค. ์ค‘์š”ํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ด๊ฒจ์ ธ ์žˆ๋Š” ๋งŒํผ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ๊ฒฝ์šฐ ์ž๋™์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋Š” ์ข…๋ฃŒ๋  ์ˆ˜ ์žˆ๊ณ  ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž๋“ค์˜ ์˜ค๋ธŒ์ ํŠธ๋“ค์„ ์ €์žฅํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ํ˜น์—ฌ๋‚˜ ์‚ฌ์šฉ์ž๋“ค์˜ ์˜ค๋ธŒ์ ํŠธ์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒจ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๊ฐ€ ์ข…๋ฃŒ๋˜๊ฑฐ๋‚˜ ์™„๋ฒฝํ•œ ๋ณต๊ตฌ๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•œ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

SYSAUX(ํ•„์ˆ˜ ์š”์†Œ)

SYSAUX Tablespace๋Š” SYSTEM Tablespace์˜ ๋ณด์กฐ๋กœ ๊ธฐ์กด์— SYSTEM Tablespace์— ์žˆ๋Š” ๋‹ค์–‘ํ•œ ์œ ํ‹ธ๋ฆฌํ‹ฐ ๋ฐ ๊ธฐ๋Šฅ๋“ค ๋ถ„๋ฆฌํ•˜์—ฌ ์ €์žฅํ•œ ๊ณต๊ฐ„์ž…๋‹ˆ๋‹ค. SYSTEM๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์šด์˜์— ํ•„์ˆ˜์ ์œผ๋กœ ์žˆ์–ด์•ผํ•˜๋Š” Tablespace์ž…๋‹ˆ๋‹ค. SYSAUX Tablespace์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ๊ฒฝ์šฐ ์‹œ์Šคํ…œ์ƒ์—๋Š” ๋ณ„ ๋‹ค๋ฅธ ๋ฌธ์ œ๊ฐ€ ์—†์ง€๋งŒ, SYSAUX Tablespace์— ์ €์žฅ๋˜์–ด ์žˆ๋Š” ์š”์†Œ๋“ค์˜ ๊ธฐ๋Šฅ๋“ค์€ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๊ฒŒ๋ฉ๋‹ˆ๋‹ค. ๋Œ€ํ‘œ์ ์œผ๋กœ AWR(Auto Workload Repository)๊ธฐ๋Šฅ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

Undo Tablespace(ํ•„์ˆ˜ ์š”์†Œ)

์ฝ๊ธฐ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” Tablespace์ž…๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์šด์˜ ์ค‘ ๋งŽ์€ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ์„œ DML ์ž‘์—…์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค. ์ด๋•Œ Rollbackํ•˜๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•˜์—ฌ DML ์ž‘์—…์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ์ˆ˜์ • ์ด์ „์˜ ๊ฐ’์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ UNDO Segment์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ Undo Segment์— ๋Œ€ํ•œ ๊ด€๋ฆฌ ๊ณต๊ฐ„์œผ๋กœ Undo Tablespace๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ๋˜๊ณ  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์šด์˜์— ์žˆ์–ด์„œ ํ•„์ˆ˜์ ์œผ๋กœ ์ ์–ด๋„ ํ•˜๋‚˜์˜ Undo Tablespace๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

 

 

Temporary Tablespace(ํ•„์ˆ˜ ์š”์†Œ)

Temporary Tablespace๋„ ํ•„์ˆ˜์ ์œผ๋กœ ์žˆ์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž ์ฟผ๋ฆฌ์˜ ์š”์ฒญ์œผ๋กœ ์ •๋ ฌํ•˜๋Š” ์ž‘์—…์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๋ฉ”๋ชจ๋ฆฌ์— ๋ถ€๋‹ด์„ ๋œ์–ด์ฃผ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ๊ณต๊ฐ„์ž…๋‹ˆ๋‹ค.

 

 

Tablespace ์ข…๋ฅ˜ ํ™•์ธ

SYS@orcl> select tablespace_name, contents from dba_tablespaces;

 

 

Tablespace ์‹ค์Šต

์‹ค์Šตํ™˜๊ฒฝ

OS : Red Hat Enterprise Linux Server release 6.10
DB : Oracle 11.2.0.1

 

Tablespace ์ƒ์„ฑ์— ๋Œ€ํ•œ ์˜ต์…˜์€ ์ •๋ง ๋งŽ์Šต๋‹ˆ๋‹ค. ๊ทธ ์ค‘์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ์˜ต์…˜๋“ค์„ ์ด๋ฒˆ ๊ธ€์—์„œ ์‹ค์Šตํ•ด๋ณผ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜ Oracle Document๋งํฌ๋ฅผ ํ†ตํ•ด ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

CREATE TABLESPACE

Purpose Use the CREATE TABLESPACE statement to create a tablespace, which is an allocation of space in the database that can contain schema objects. A permanent tablespace contains persistent schema objects. Objects in permanent tablespaces are stored in d

docs.oracle.com

 

Create Permanent Tablespace

CREATE
[BIGFILE | SMALLFILE(๊ธฐ๋ณธ๊ฐ’)]
TABLESPACE <ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…>
DATAFILE '<๊ฒฝ๋กœ>' SIZE <ํฌ๊ธฐ>
[EXTENT MANAGEMENT
	[
    	DICTIONARY | LOCAL(๊ธฐ๋ณธ๊ฐ’) [AUTOALLOCATE(๊ธฐ๋ณธ๊ฐ’) | UNIFORM SIZE <ํฌ๊ธฐ>]
    ]
]
[SEGMENT SPACE MANAGEMENT [AUTO(๊ธฐ๋ณธ๊ฐ’) | MANUAL]]

Tablespace ์ƒ์„ฑ์— ์žˆ์–ด์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ผญ ์•Œ์•„์•ผํ•  ์˜ต์…˜๋“ค์ž…๋‹ˆ๋‹ค.

 

 

๊ธฐ๋ณธ ์ƒ์„ฑ
SYS@orcl> create tablespace abc
datafile '/opt/oracle/dbf/abc.dbf' size 50m;
SYS@orcl> select
    tablespace_name
    ,contents
    ,extent_management
    ,allocation_type
    ,segment_space_management
    ,bigfile 
from dba_tablespaces 
where tablespace_name = 'ABC'

ํ•„์ˆ˜์ ์ธ ์ •๋ณด๋งŒ ์ž…๋ ฅํ•˜์—ฌ Tablespace๋ฅผ ์ƒ์„ฑํ•ด๋ดค์Šต๋‹ˆ๋‹ค. ์ข…๋ฅ˜๋Š” PERMANENT์ด๊ณ  ๋‹ค๋ฅธ ์˜ต์…˜์€ ๊ธฐ์ž…ํ•˜์ง€ ์•Š์•„ SMALL FILE๋กœ EXTENT_MANAGEMENT๋Š” LOCAL ๊ทธ๋ฆฌ๊ณ  SEGMENT_SPACE_MANAGEMENT๋Š” AUTO ํ˜•ํƒœ๋กœ ์ €์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

BIGFILE
SQL@orcl> create bigfile tablespace abc
datafile '/opt/oracle/dbf/abc.dbf' size 100m;
SYS@orcl> select
    tablespace_name
    ,contents
    ,extent_management
    ,allocation_type
    ,segment_space_management
    ,bigfile 
from dba_tablespaces 
where tablespace_name = 'ABC'

BIGFILE๊ณผ SMALL FILE์˜ ๊ฐ€์žฅ ํฐ ์ฐจ์ด๋Š” ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐํŒŒ์ผ์˜ ๊ฐฏ์ˆ˜์™€ ํฌ๊ธฐ ์ž…๋‹ˆ๋‹ค. BIGFILE์˜ ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐํŒŒ์ผ์€ ๋”ฑ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. BIGFILE์€ ASM(Automatic Storage Management)์ด ์ƒ๊ธฐ๋ฉด์„œ ๋งŒ๋“ค์–ด์กŒ์Šต๋‹ˆ๋‹ค. BIGFILE์ด ๋‚˜์˜ค๊ธฐ ์ „์— SMALLFILE์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋””์Šคํฌ์— ๊ท ๋“ฑํ•˜๊ฒŒ ์ˆ˜๋™์œผ๋กœ ๋ฐ์ดํ„ฐํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์คฌ์Šต๋‹ˆ๋‹ค. ASM์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉด ์ž๋™์œผ๋กœ ๊ท ๋“ฑํ•˜๊ฒŒ ๋””์Šคํฌ๋ณ„๋กœ ๊ณต๊ฐ„์„ ํ• ๋‹นํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ๊ตณ์ด ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ฐ์ดํ„ฐํŒŒ์ผ์˜ ๊ด€๋ฆฌํ•  ํ•„์š” ์—†์ด ํ•˜๋‚˜์˜ ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ณ  ASM์œผ๋กœ ๊ณต๊ฐ„์„ ํ• ๋‹นํ•˜๋ฉด ๋” ์‰ฝ๊ฒŒ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์–ด BIGFILE์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

 

EXTENT MANAGEMENT

Tablespace์˜ ๊ณต๊ฐ„ ํ• ๋‹น์€ Extent ๋‹จ์œ„๋กœ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค. DML ์ž‘์—…์ด ๊ณ„์† ๋ฐ˜๋ณต๋˜๋ฉด์„œ Extent์˜ ํ• ๋‹น๊ณผ ๋ฐ˜ํ™˜์ด ๋ฐœ์ƒํ•˜๋Š”๋ฐ ์–ด๋Š Extent๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋˜๋Š”์ง€์— ๋Œ€ํ•œ ์ •๋ณด ๊ด€๋ฆฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ EXTENT MANAGEMENT์—๋Š” DICTIONARY์™€ LOCAL ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

DICTIONARY(๊ตฌ์‹)

์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ Extent์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ Data Dictionary์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์ด๋ฐฉ๋ฒ•์€ ๊ฐ Segment๋งˆ๋‹ค ๋‹ค๋ฅธ Extent ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์ฟผ๋ฆฌ ์ž‘์—…์ด๋‚˜ DML์ž‘์—…์„ ํ• ๋•Œ๋งŒ์œผ๋กœ๋„ ๋‚ด๋ถ€์ ์œผ๋กœ ๋งŽ์€ ์–‘์˜ Data Dictionary ์กฐํšŒ ์ž‘์—…์ด ๋ฐœ์ƒํ•˜๋Š”๋ฐ Extent ๊ด€๋ฆฌ๊นŒ์ง€ ํ•˜๊ฒŒ๋˜๋ฉด Data Dictionary์— ๋Œ€ํ•œ ๊ฒฝํ•ฉ๋ฐœ์ƒ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’์•„ ํ˜„์žฌ๋Š” ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.

 

LOCAL

Data File์˜ ํ—ค๋”์— ๋น„ํŠธ๋งต์„ ํ†ตํ•ด Extent์˜ ์‚ฌ์šฉ ์œ ๋ฌด๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ๊ฐ Datafile์— ๋น„ํŠธ๋งต์„ ์‚ฌ์šฉํ•˜์—ฌ Resource์˜ ์‚ฌ์šฉ๋Ÿ‰์ด ๋†’์•„์ง€์ง€๋งŒ Data Dictionary Table ์ฒ˜๋Ÿผ ์ค‘์š”ํ•œ ์˜ค๋ธŒ์ ํŠธ์˜ ๊ฒฝํ•ฉ์„ ์ค„์ด๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•˜๋‹ค. ๊ธฐ๋ณธ๊ฐ’์ธ AUTOALLOCATE ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฉด ์ž๋™์œผ๋กœ Extent์˜ ํฌ๊ธฐ๋ฅผ ์ •ํ•˜๋„๋ก ์œ„์ž„ ๊ฐ€๋Šฅํ•˜๊ณ  UNIFORM ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ชจ๋“  Extent์˜ ํฌ๊ธฐ๋ฅผ ๋™์ผํ•˜๊ฒŒ ์„ค์ • ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

SYS@orcl> create tablespace abc
datafile '/opt/oracle/dbf/abc.dbf' size 20m
extent management local uniform size 1m;
SYS@orcl> select 
    tablespace_name
    ,initial_extent
    ,next_extent
    ,extent_management
    ,allocation_type
    ,segment_space_management 
from dba_tablespaces
where tablespace_name = 'ABC';

์ฒซ๋ฒˆ์งธ Extent์™€ ๋‹ค์Œ Extent์˜ ํฌ๊ธฐ ๋ชจ๋‘ 1MB์ธ๊ฒƒ์ด ํ™•์ธ๋˜๊ณ  ALLOCATION_TYPE์ด UNIFORM์œผ๋กœ ๋ณ€๊ฒฝ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

SEGMENT SPACE MANAGEMENT

Segment์˜ ๊ณต๊ฐ„ ๊ด€๋ฆฌ์— ๋Œ€ํ•œ ์˜ต์…˜์ž…๋‹ˆ๋‹ค. ์‰ฝ๊ฒŒ ์ƒ๊ฐํ•ด์„œ ํ…Œ์ด๋ธ”์˜ ๊ณต๊ฐ„ ๊ด€๋ฆฌ๋ฅผ ์–ด๋–ป๊ฒŒ ํ• ๊ฒƒ์ธ๊ฐ€...๋ฅผ ๋ฌป๋Š” ์˜ต์…˜์ž…๋‹ˆ๋‹ค. ํ˜„์žฌ๋Š” AUTO ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

 

MANUAL(๊ตฌ์‹)

Manual ๋ฐฉ๋ฒ•์€ Freelist๋ฅผ ์‚ฌ์šฉํ•ด์„œ Insert๊ฐ€ ๊ฐ€๋Šฅํ•œ ๋ธ”๋Ÿญ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ…Œ์ด๋ธ” ์ƒ์„ฑ์‹œ ๋ธ”๋Ÿญ์ด ์ผ์ • ๋ฐฑ๋ถ„์œ„ ์ดํ•˜๋กœ ์‚ฌ์ด์ฆˆ๊ฐ€ ์ค„์–ด๋“ค๋ฉด ๋‹ค์‹œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ๋ธ”๋Ÿญ์œผ๋กœ Freelist์— ๋“ฑ๋กํ•˜๋Š” PCTUSED๋ผ๋Š” ๊ธฐ์ค€์„ ์ •ํ•ด์ฃผ๋Š” ์˜ต์…˜์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์ด PCTUSED ์„ค์ •์œผ๋กœ ์ธํ•ด ๊ณต๊ฐ„์ด ์žˆ์Œ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  Extent๋ฅผ ๊ณ„์† ๋งŒ๋“ค์–ด์•ผํ•˜๋Š” ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

 

๊ฐ ๋ธ”๋ก์— ๋‚˜๋ฆ„ ๊ณจ๊ณ ๋ฃจ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ถ„ํฌ๋˜์–ด ๋ชจ๋‘ ์„ค์ •ํ•œ PCTUSED ์ดํ•˜๋กœ ์•ˆ๋‚ด๋ ค์˜ค๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ๊ฒฝ์šฐ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ๋ธ”๋Ÿญ์ด ์—†๋Š”๊ฒƒ์œผ๋กœ Freelist์—์„œ ์ธ์‹๋˜์–ด ์ƒˆ๋กœ์šด Extent๋ฅผ ํ• ๋‹นํ•ด์•ผํ•˜๋Š” ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด AUTO ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

AUTO

๋น„ํŠธ๋งต์„ ์ด์šฉํ•ด์„œ ๋น„์–ด์žˆ๋Š” ๋ธ”๋ก์„ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. PCTUSED ์˜ต์…˜์ด ์‚ฌ๋ผ์ง€๊ณ  ์•„๋ž˜์™€ ๊ฐ™์ด ๋น„์–ด์žˆ๋Š” ๊ณต๊ฐ„์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.

fs1 0 ~ 25%
fs2 25 ~ 50%
fs3 50 ~ 75%
fs4 75 ~ 100%
full INSERT X
never used O

4๊ฐœ ๋“ฑ๊ธ‰์œผ๋กœ ๋‚˜๋ˆ„๊ณ  ์ด 6๊ฐ€์ง€ ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” Bitmap ๋ธ”๋Ÿญ์„ ์‚ฌ์šฉํ•˜์—ฌ  segment๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฐฉ๋ฒ•์„ ASSM(Automatic Space Segment Management)๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

 

 

Create Temporary Tablespace

CREATE
[BIGFILE | SMALLFILE(๊ธฐ๋ณธ๊ฐ’)]
TEMPORARY TABLESPACE <ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…>
TEMPFILE '<๊ฒฝ๋กœ>' SIZE <ํฌ๊ธฐ>
[EXTENT MANAGEMENT
	[
    	DICTIONARY | LOCAL(๊ธฐ๋ณธ๊ฐ’) [UNIFORM SIZE <ํฌ๊ธฐ>(๊ธฐ๋ณธ๊ฐ’ 1M)]]
    ]
]

Temporary Tablespace๋Š” ๊ธฐ๋ณธ์ ์€๋กœ LOCAL UNIFORM SIZE 1M ์ด๊ณ  SEGMENT SPACE MANAGEMENT๋Š” AUTO๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

 

SYS@orcl> create temporary tablespace abc
tempfile '/opt/oracle/dbf/abc.tmp' size 20m;
SYS@orcl> select 
    tablespace_name
    ,contents
    ,initial_extent
    ,next_extent
    ,extent_management
    ,allocation_type
    ,segment_space_management 
from dba_tablespaces
where tablespace_name = 'ABC';

 

 

Default Temporary Tablespace ๋ณ€๊ฒฝ

select * from database_properties where property_name like 'DEFAULT_TEMP%'

 

alter database default temporary tables=<ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…>

์œ„๋ช…๋ น์œผ๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

 

Create Undo Tablespace

CREATE
[BIGFILE | SMALLFILE(๊ธฐ๋ณธ๊ฐ’)]
UNDO TABLESPACE <ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…>
DATAFILE '<๊ฒฝ๋กœ>' SIZE <ํฌ๊ธฐ>
[EXTENT MANAGEMENT
	[
    	DICTIONARY | LOCAL(๊ธฐ๋ณธ๊ฐ’) [AUTOALLOCATE(๊ธฐ๋ณธ๊ฐ’)]
    ]
]

Undo Tablespace๋Š” UNIFORM SIZE๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์—†๊ณ  Segment Space Management๋„ MANUAL๋งŒ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

SYS@orcl> create undo tablespace abc
datafile '/opt/oracle/dbf/abc.dbf' size 20m;
SYS@orcl> select 
    tablespace_name
    ,contents
    ,initial_extent
    ,next_extent
    ,extent_management
    ,allocation_type
    ,segment_space_management 
from dba_tablespaces
where tablespace_name = 'ABC';

 

 

Default Undo Tablespace ๋ณ€๊ฒฝ

SYS@orcl> show parameter undo_tablespace

 

SYS@orcl> alter system set undo_tablespace=<ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…>

์œ„ ๋ช…๋ น์œผ๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

 

Tablespace Datafile ์ถ”๊ฐ€, ์‚ญ์ œ

์ถ”๊ฐ€

SYS@orcl> alter tablespace users add datafile '/opt/oracle/app/oradata/orcl/users02.dbf' size 10m;
select 
    tablespace_name
    ,file_name 
from dba_data_files 
where tablespace_name = 'USERS';

 

 

์‚ญ์ œ

select tablespace_name, file_id, file_name from dba_data_files where tablespace_name = 'USERS';

SYS@orcl> alter tablespace users drop datafile 6;

file id ํ˜น์€ file_name ์ „์ฒด ๊ฒฝ๋กœ๋กœ ์‚ญ์ œ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

 

Tablespace ์‚ญ์ œ

drop tablespace <ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋ช…> including contents and datafiles;

contents : ๋ชจ๋“  ์„ธ๊ทธ๋จผํŠธ๋ฅผ ์‚ญ์ œ

datafiles : ๋ชจ๋“  ๋ฐ์ดํ„ฐํŒŒ์ผ๊นŒ์ง€ ์‚ญ์ œ

 

๋Œ“๊ธ€