- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2012-8-9 22:11:49
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
SQL> create smallfile tablespace lmt_10m datafile size 100m extent management local uniform size 10m ;
Tablespace created.
SQL> create smallfile tablespace lmt_20m datafile size 100m extent management local uniform size 20M;
Tablespace created.
SQL> create smallfile tablespace lmt_64k datafile size 100m extent management local uniform size 64k;
Tablespace created.
SQL> create smallfile tablespace lmt_90M datafile size 100m extent management local uniform size 90M;
Tablespace created.
SQL> select tablespace_name,file_name,(bytes-user_bytes)/1024/1024||'M' from dba_data_files where tablespace_name like 'LMT%';
TABLESPACE_NAME FILE_NAME (BYTES-USER_BYTES)/1024/1024||'M'
------------------------------ ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------
LMT_10M /s01/oradata/G10R25/datafile/o1_mf_lmt_10m_827hq2ks_.dbf 10M
LMT_20M /s01/oradata/G10R25/datafile/o1_mf_lmt_20m_827jm0nv_.dbf 20M
LMT_64K /s01/oradata/G10R25/datafile/o1_mf_lmt_64k_827jy8xf_.dbf .0625M
LMT_90M /s01/oradata/G10R25/datafile/o1_mf_lmt_90m_827k15hz_.dbf 10M
10g 中smallfile datafile header(默认情况下)实际只占8个块
SQL> select tablespace_name , block_id,blocks from dba_free_space where tablespace_name like 'LMT%';
TABLESPACE_NAME BLOCK_ID BLOCKS
------------------------------ ---------- ----------
LMT_10M 9 11520
LMT_20M 9 10240
LMT_64K 9 12792
LMT_90M 9 11520
11520*8k=90M
10240*8k=80M
结论当使用LOCAL Management Extent + UNIFORM SIZE的情况下
bytes-user_bytes=总是等于datafile size取余 (UNIFORM SIZE )
SQL> select ktfbfeblks from sys.x$ktfbfe;
KTFBFEBLKS
----------
56
32
32
32
32
32
32
32
32
1272
32
KTFBFEBLKS
----------
24
16
104
17920
275960
48
632
8
24
48
145664
KTFBFEBLKS
----------
16344
4000
600
1264
1256
1216
12792
25592
11520
10240
12792
KTFBFEBLKS
----------
11520
数据存放是从第9个块开始的
create or replace view DBA_DATA_FILES
(FILE_NAME, FILE_ID, TABLESPACE_NAME,
BYTES, BLOCKS, STATUS, RELATIVE_FNO, AUTOEXTENSIBLE,
MAXBYTES, MAXBLOCKS, INCREMENT_BY, USER_BYTES, USER_BLOCKS, ONLINE_STATUS)
as
select v.name, f.file#, ts.name,
ts.blocksize * f.blocks, f.blocks,
decode(f.status$, 1, 'INVALID', 2, 'AVAILABLE', 'UNDEFINED'),
f.relfile#, decode(f.inc, 0, 'NO', 'YES'),
ts.blocksize * f.maxextend, f.maxextend, f.inc,
ts.blocksize * (f.blocks - 1), f.blocks - 1,
decode(fe.fetsn, 0, decode(bitand(fe.festa, 2), 0, 'SYSOFF', 'SYSTEM'),
decode(bitand(fe.festa, 18), 0, 'OFFLINE', 2, 'ONLINE', 'RECOVER'))
from sys.file$ f, sys.ts$ ts, sys.v$dbfile v, x$kccfe fe
where v.file# = f.file#
and f.spare1 is NULL
and f.ts# = ts.ts#
and fe.fenum = f.file#
union all
select
v.name,f.file#, ts.name,
decode(hc.ktfbhccval, 0, ts.blocksize * hc.ktfbhcsz, NULL),
decode(hc.ktfbhccval, 0, hc.ktfbhcsz, NULL),
decode(f.status$, 1, 'INVALID', 2, 'AVAILABLE', 'UNDEFINED'),
f.relfile#,
decode(hc.ktfbhccval, 0, decode(hc.ktfbhcinc, 0, 'NO', 'YES'), NULL),
decode(hc.ktfbhccval, 0, ts.blocksize * hc.ktfbhcmaxsz, NULL),
decode(hc.ktfbhccval, 0, hc.ktfbhcmaxsz, NULL),
decode(hc.ktfbhccval, 0, hc.ktfbhcinc, NULL),
decode(hc.ktfbhccval, 0, hc.ktfbhcusz * ts.blocksize, NULL),
decode(hc.ktfbhccval, 0, hc.ktfbhcusz, NULL),
decode(fe.fetsn, 0, decode(bitand(fe.festa, 2), 0, 'SYSOFF', 'SYSTEM'),
decode(bitand(fe.festa, 18), 0, 'OFFLINE', 2, 'ONLINE', 'RECOVER'))
from sys.v$dbfile v, sys.file$ f, sys.x$ktfbhc hc, sys.ts$ ts, x$kccfe fe
where v.file# = f.file#
and f.spare1 is NOT NULL
and v.file# = hc.ktfbhcafno
and hc.ktfbhctsn = ts.ts#
and fe.fenum = f.file#
/
f.blocks - 1=》sys.file$.blocks - 1 => USER_BLOCKS
hc.ktfbhccval=> x$ktfbhc.ktfbhccval-1 =>USER_BLOCKS
create or replace view DBA_FREE_SPACE
(TABLESPACE_NAME, FILE_ID, BLOCK_ID,
BYTES, BLOCKS, RELATIVE_FNO)
as
select ts.name, fi.file#, f.block#,
f.length * ts.blocksize, f.length, f.file#
from sys.ts$ ts, sys.fet$ f, sys.file$ fi
where ts.ts# = f.ts#
and f.ts# = fi.ts#
and f.file# = fi.relfile#
and ts.bitmapped = 0
union all
select /*+ ordered use_nl(f) use_nl(fi) */
ts.name, fi.file#, f.ktfbfebno,
f.ktfbfeblks * ts.blocksize, f.ktfbfeblks, f.ktfbfefno
from sys.ts$ ts, sys.x$ktfbfe f, sys.file$ fi
where ts.ts# = f.ktfbfetsn
and f.ktfbfetsn = fi.ts#
and f.ktfbfefno = fi.relfile#
and ts.bitmapped <> 0 and ts.online$ in (1,4) and ts.contents$ = 0
union all
select /*+ ordered use_nl(u) use_nl(fi) */
ts.name, fi.file#, u.ktfbuebno,
u.ktfbueblks * ts.blocksize, u.ktfbueblks, u.ktfbuefno
from sys.recyclebin$ rb, sys.ts$ ts, sys.x$ktfbue u, sys.file$ fi
where ts.ts# = rb.ts#
and rb.ts# = fi.ts#
and u.ktfbuefno = fi.relfile#
and u.ktfbuesegtsn = rb.ts#
and u.ktfbuesegfno = rb.file#
and u.ktfbuesegbno = rb.block#
and ts.bitmapped <> 0 and ts.online$ in (1,4) and ts.contents$ = 0
union all
select ts.name, fi.file#, u.block#,
u.length * ts.blocksize, u.length, u.file#
from sys.ts$ ts, sys.uet$ u, sys.file$ fi, sys.recyclebin$ rb
where ts.ts# = u.ts#
and u.ts# = fi.ts#
and u.segfile# = fi.relfile#
and u.ts# = rb.ts#
and u.segfile# = rb.file#
and u.segblock# = rb.block#
and ts.bitmapped = 0
/
sys.x$ktfbfe.ktfbfeblks |
|