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

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:ORACLEPRODUCT10.2.0ORADATAEDWTESTAPP04.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;

经验分享 程序员 微信小程序 职场和发展