领导交给我一个任务,让我统计一个表的占用空间。这个表包含一个大字段CLOB,对于这种表,应该怎样统计这个表占用空间的大小?
听说CLOB,是一个引用,会把真实内容放到其他地方,会放在那里?对CLOB这样的表怎么统计?create table test2
(
TEST_SEQ NUMBER(22) not null,
TEST_CONTENT CLOB,
RESERVE_TIME DATE
)请高手指教?
听说CLOB,是一个引用,会把真实内容放到其他地方,会放在那里?对CLOB这样的表怎么统计?create table test2
(
TEST_SEQ NUMBER(22) not null,
TEST_CONTENT CLOB,
RESERVE_TIME DATE
)请高手指教?
where segment_name in
(
select segment_name
from user_lobs
where table_name= 'TEST2'
); Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents WHERE segment_name='TEST2' GROUP BY SEGMENT_NAME
两者数值相加
--示例,求LOB段的大小
SQL> select dbms_lob.getLength(RULE_CONDITION ) from DBA_RULES;
DBMS_LOB.GETLENGTH(RULE_CONDIT
------------------------------
33
30
31
85
LOB(b)
STORE AS lobsegname (
TABLESPACE lobsegts
STORAGE (lobsegment storage clause)
[CHUNK 8K disable storage in row]
INDEX lobindexname (
TABLESPACE lobidxts
STORAGE ( lobindex storage clause )
)
)
TABLESPACE tables_ts
STORAGE( tables storage clause );
其中,store as (enable storage in row|disable storage in row)表示是否允许lob数据保存在行内(与其他字段数据放在表段)。对于enable storage in row,表示允许小于4000字节的lob字段信息保存在表段,是默认值,对于大于4000字节的lob字段保存在lob段(同disable storage in row),在表段将保留36-84字节的控制信息。对于disable storage in row,Oracle将lob字段分开保存在lob段中,而仅仅在行位置保留20字节的指针。对于相当于disable storage in row的这部分(也就是单独保存在LOB段的这部分数据),UNDO仅仅是记录指针与相关lob索引改变,如果发生更新操作等DML操作,原始数据将保留在LOB段。