1. 查看所有表空间大小
SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
2. 已经空闲的表空间大小
SQL> select tablespace_name,sum(bytes)/1024/1024 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.查看所有表空间对应的数据文件:
select tablespace_name,file_name from dba_data_files;
5.增加表空间大小的四种方法
Meathod1:给表空间增加数据文件
ALTER TABLESPACE USERS ADD DATAFILE ‘+HISDATA/his/datafile/users01.DBF‘ SIZE 10240M;
Meathod2:新增数据文件,并且允许数据文件自动增长
ALTER TABLESPACE app_data ADD DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP04.DBF‘ SIZE 50M
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
Meathod3:允许已存在的数据文件自动增长
ALTER DATABASE DATAFILE ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF‘
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
Meathod4:手工改变已存在数据文件的大小
ALTER DATABASE DATAFILE ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP02.DBF‘
RESIZE 100M;