oracle查看表空间及增加表空间方法

  • Post author:
  • Post category:其他


1. 查看所有表空间大小

select tablespace_name,(sum(bytes)/1024/1024) tablespace_size from dba_data_files group by tablespace_name;


2. 未使用的表空间大小

select tablespace_name,(sum(bytes)/1024/1024) tablespace_size from dba_free_space group by tablespace_name;


3. 所以使用空间可以这样计算

select a.tablespace_name,total,free,total-free used from

( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files

group by tablespace_name) a,

( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space

group by tablespace_name) b

where a.tablespace_name=b.tablespace_name;


4. 查看所有segment的大小。

Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

查询所有的表空间

select tablespace_name from dba_tablespaces

5. 查看表空间中分布的用户信息

select tablespace_name, owner,sum(bytes) from dba_segments

group by tablespace_name, owner

6.增加表空间大小的四种方法

6.1:给表空间增加数据文件

alter tablespace USERS add datafile ‘/home/oracle/app/oracle/oradata/helowin/users02.dbf’ size 5G;

6.2:新增数据文件,并且允许数据文件自动增长

ALTER TABLESPACE app_data ADD DATAFILE

‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP04.DBF’ SIZE 50M

AUTOEXTEND ON NEXT 5M MAXSIZE 100M;

6.3:允许已存在的数据文件自动增长

ALTER DATABASE DATAFILE ‘/home/oracle/app/oracle/oradata/helowin/users01.dbf’ AUTOEXTEND ON NEXT 5M MAXSIZE 10240M;

6.4:手工改变已存在数据文件的大小

ALTER DATABASE DATAFILE ”/home/oracle/app/oracle/oradata/helowin/users01.dbf’

RESIZE 100M;



版权声明:本文为u010006625原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。