您在这里:首页 > 学员专区 > 技术文章
Oracle视频
Oracle
CUUG课程

管理表空间(十二)--监控表空间

 

1、查看表空间空闲大小

09:47:04 SQL> select TABLESPACE_NAME,sum(bytes)/1024/1024 from dba_free_space

09:47:33   2    group by tablespace_name;

TABLESPACE_NAME                SUM(BYTES)/1024/1024

------------------------------ --------------------

SYSAUX                                      51.0625

LX01                                              9

UNDO_TBS01                                   8.6875

LX02                                      9.9921875

RTBS                                        18.6875

USERS                                            16

OLTP                                             46

TEST                                         59.875

SYSTEM                                   131.890625

EXAMPLE                                         399

INDX                                        39.9375

2、表空间数据文件的监控:

13:46:54 SQL> DESC v$filestat

Name                                                                                Null?    Type

----------------------------------------------------------------------------------- -------- -----------------------

FILE#                                                                                        NUMBER

PHYRDS                                                                                       NUMBER

PHYWRTS                                                                                      NUMBER

PHYBLKRD                                                                                     NUMBER

PHYBLKWRT                                                                                    NUMBER

SINGLEBLKRDS                                                                                 NUMBER

READTIM                                                                                      NUMBER

WRITETIM                                                                                     NUMBER

SINGLEBLKRDTIM                                                                               NUMBER

AVGIOTIM                                                                                     NUMBER

LSTIOTIM                                                                                     NUMBER

MINIOTIM                                                                                     NUMBER

MAXIORTM                                                                                     NUMBER

MAXIOWTM                                                                                     NUMBER

13:52:15 SQL> select file#,phyrds,phywrts,phyblkrd,phyblkwrt from v$filestat;

FILE#     PHYRDS    PHYWRTS   PHYBLKRD  PHYBLKWRT

---------- ---------- ---------- ---------- ----------

1       5301        294       6272        411

2        410        518        410        929

3       1113       1000       2481       1378

4         24         10         36         27

5          6          1          6          1

6          6          1          6          1

7          4          1          4          1

7 rows selected.

3、查看表空间使用率

select a.tablespace_name,

round(a.total_size) "total_size(mb)",

round(a.total_size) - round(b.free_size,3) "unsed_size(mb)",

round(b.free_size,3) "free_size(mb)",

round(b.free_size/total_size *100,2) ||'%' free_rate

from

(select tablespace_name,sum(bytes) /1024/1024 total_size

from dba_data_files

group by tablespace_name) a,

(select tablespace_name,sum(bytes)/1024/1024 free_size

from dba_free_space

group by tablespace_name) b

where a.tablespace_name=b.tablespace_name(+);

05:08:02 SQL> select a.tablespace_name,

round(a.total_size) "total_size(mb)",

round(a.total_size) - round(b.free_size,3) "unsed_size(mb)",

(select tablespace_name,sum(bytes) /1024/1024 total_size

round(b.free_size,3) "free_size(mb)",

round(b.free_size/total_size *100,2) ||'%' free_rate

from

(select tablespace_name,sum(bytes) /1024/1024 total_size

from dba_data_files

group by tablespace_name) a,

(select tablespace_name,sum(bytes)/1024/1024 free_size

from dba_free_space

group by tablespace_name) b

05:08:03  13   where a.tablespace_name=b.tablespace_name(+);

TABLESPACE_NAME                total_size(mb) unsed_size(mb) free_size(mb) FREE_RATE

------------------------------ -------------- -------------- ------------- -----------------------------------------

UNDOTBS1                                   90             19            71 78.89%

SYSAUX                                    290        286.125         3.875 1.34%

USERS01                                    20          1.625        18.375 91.88%

USERS                                      11          3.812         7.188 63.89%

UNDOTBS                                    20           11.5           8.5 42.5%

SYSTEM                                    490        485.625         4.375 .89%

EXAMPLE                                   100          68.25         31.75 31.75%

BIG_TBS                                    10           .125         9.875 98.75%

USERS03                                    10           .125         9.875 98.75%

UNDOTBS02                                  10          9.562          .438 4.38%

USERS02                                    10            .25          9.75 97.5%

TBS_16K01                                  10           .062         9.938 99.38%

USERS04                                    10           .125         9.875 98.75%

13 rows selected.

05:08:36 SQL> alter tablespace system

05:09:05   2   add datafile '/u01/app/oracle/oradata/orcl/system02.dbf' size 200m;

Tablespace altered.

05:09:59 SQL> select a.tablespace_name,

round(a.total_size) "total_size(mb)",

round(a.total_size) - round(b.free_size,3) "unsed_size(mb)",

round(b.free_size,3) "free_size(mb)",

(select tablespace_name,sum(bytes) /1024/1024 total_size

round(b.free_size/total_size *100,2) ||'%' free_rate

from

(select tablespace_name,sum(bytes) /1024/1024 total_size

from dba_data_files

group by tablespace_name) a,

(select tablespace_name,sum(bytes)/1024/1024 free_size

from dba_free_space

group by tablespace_name) b

05:10:03  13   where a.tablespace_name=b.tablespace_name(+);

TABLESPACE_NAME                total_size(mb) unsed_size(mb) free_size(mb) FREE_RATE

------------------------------ -------------- -------------- ------------- -----------------------------------------

UNDOTBS1                                   90             19            71 78.89%

SYSAUX                                    290        286.125         3.875 1.34%

USERS01                                    20          1.625        18.375 91.88%

USERS                                      11          3.812         7.188 63.89%

UNDOTBS                                    20           11.5           8.5 42.5%

SYSTEM                                    690        485.687       204.313 29.61%

EXAMPLE                                   100          68.25         31.75 31.75%

BIG_TBS                                    10           .125         9.875 98.75%

USERS03                                    10           .125         9.875 98.75%

UNDOTBS02                                  10          9.562          .438 4.38%

USERS02                                    10            .25          9.75 97.5%

TBS_16K01                                  10           .062         9.938 99.38%

USERS04                                    10           .125         9.875 98.75%

13 rows selected.

05:34:09 SQL> alter database

05:34:27   2    datafile '/u01/app/oracle/oradata/orcl/system02.dbf' resize 300m;

Database altered.

01:48:50 SQL> alter database

01:48:52   2  datafile '/ora_data/oradata/prod/system01.dbf'

01:49:09   3    autoextend on next 10m maxsize 1000m;

Database altered.

05:34:33 SQL> select a.tablespace_name,

round(a.total_size) "total_size(mb)",

round(a.total_size) - round(b.free_size,3) "unsed_size(mb)",

round(b.free_size,3) "free_size(mb)",

round(b.free_size/total_size *100,2) ||'%' free_rate

from

(select tablespace_name,sum(bytes) /1024/1024 total_size

from dba_data_files

group by tablespace_name) a,

(select tablespace_name,sum(bytes)/1024/1024 free_size

from dba_free_space

group by tablespace_name) b

05:34:46  13   where a.tablespace_name=b.tablespace_name(+);

TABLESPACE_NAME                total_size(mb) unsed_size(mb) free_size(mb) FREE_RATE

------------------------------ -------------- -------------- ------------- -----------------------------------------

UNDOTBS1                                   90             19            71 78.89%

SYSAUX                                    290        286.125         3.875 1.34%

USERS01                                    20          1.625        18.375 91.88%

USERS                                      11          3.812         7.188 63.89%

UNDOTBS                                    20           11.5           8.5 42.5%

SYSTEM                                    790        485.687       304.313 38.52%

EXAMPLE                                   100          68.25         31.75 31.75%

BIG_TBS                                    10           .125         9.875 98.75%

USERS03                                    10           .125         9.875 98.75%

UNDOTBS02                                  10          9.562          .438 4.38%

USERS02                                    10            .25          9.75 97.5%

TBS_16K01                                  10           .062         9.938 99.38%

USERS04                                    10           .125         9.875 98.75%

13 rows selected.

相关文章 [上一篇] 管理表空间(十一)--显示表空间和数据文件
010-88589926(88587026)
CUUG热门培训课程
Oracle DBA就业培训
CUUG名师
网络课程
技术沙龙
最新动态

总机:(010)-88589926,88589826,88587026 QQ讨论群:243729577 182441349 邮箱:cuug_bj@cuug.com
通信地址:北京市海淀区紫竹院路98号北京化工大学科技园609室(CUUG)邮政编码:100089 
中国UNIX用户协会 Copyright 2010  ALL Rights Reserved 北京神脑资讯技术有限公司
京ICP备11008061号  京公网安备110108006275号