oracle dba_temp_files,Oracle Data & Temp Files Management

CREATE TABLESPACE bowie_data

DATAFILE 'c:\bowie\bowie_data01.dbf' size 10m,

'c:\bowie\bowie_data02.dbf' size 10m,

'c:\bowie\bowie_data03.dbf' size 10m

uniform size 64;

col segment_name format a30

SELECT file_id, file_name

FROM dba_data_files

WHERE tablespace_name = 'BOWIE_DATA';

CREATE TABLE one (x NUMBER) TABLESPACE bowie_data;

CREATE TABLE two (x NUMBER) TABLESPACE bowie_data;

CREATE TABLE three (x NUMBER) TABLESPACE bowie_data;

CREATE TABLE four (x NUMBER) TABLESPACE bowie_data;Now we've create 4 tables in this tablespace. Let's see which data file they were placed

in ...SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA';Note that *all* tables have their first extent created in the *first* data file defined to

the tablespace.

Now lets grow these tables and see what happens next.ALTER TABLE one ALLOCATE EXTENT;

ALTER TABLE two ALLOCATE EXTENT;

ALTER TABLE three ALLOCATE EXTENT;

ALTER TABLE four ALLOCATE EXTENT;

SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA'

ORDER BY segment_name;... and the second extent of each table has been created in the second data file of the

tablespace.

If a particular table were to keep growing ...ALTER TABLE four ALLOCATE EXTENT;

ALTER TABLE four ALLOCATE EXTENT;

SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA'

ORDER BY segment_name;You can see how the extents get allocated to the data files in a round robin fashion. But

the first extent is allocate to the first data file (providing it has sufficent space) ...CREATE TABLE five (x NUMBER) TABLESPACE bowie_data;

SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA'

ORDER BY segment_name;Let's add a new data file. What happens now ...ALTER TABLESPACE bowie_data

ADD DATAFILE 'c:\bowie\bowie_data04.dbf' SIZE 10M;

ALTER TABLE four ALLOCATE EXTENT;

SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA'

ORDER BY segment_name;A new extent is added to table four. And uses the new datafile.ALTER TABLE four ALLOCATE EXTENT;

SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA'

ORDER BY segment_name;

ALTER TABLE four ALLOCATE EXTENT;

SELECT segment_name, file_id

FROM dba_extents

WHERE tablespace_name = 'BOWIE_DATA'

ORDER BY segment_name;... and now the new file is used. The files are still used in a round robin fashion with

the new file slipping in.

Note how file 16 is the *most* used file and file 19 is the least. If I were to allocate

several new tables that were only 1 or 2 extents in size, see how file 16 would be the one

to be most "filled".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值