ORACLE表空间查看和扩展

1、查看表空间使用情况

SELECT a.tablespace_name "表空间名", 
total "表空间大小", 
free "表空间剩余大小", 
(total - free) "表空间使用大小", 
total / (1024 * 1024 * 1024) "表空间大小(G)", 
free / (1024 * 1024 * 1024) "表空间剩余大小(G)", 
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)", 
round((total - free) / total, 4) * 100 "使用率 %" 
FROM (SELECT tablespace_name, SUM(bytes) free 
FROM dba_free_space 
GROUP BY tablespace_name) a, 
(SELECT tablespace_name, SUM(bytes) total 
FROM dba_data_files 
GROUP BY tablespace_name) b 
WHERE a.tablespace_name = b.tablespace_name 

2、查看表空间文件大小

select tablespace_name, file_id, file_name,round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name;

3、更改表空间文件大小

alter database datafile '/u01/oradata/orcl/users01.dbf' resize 33000m;  

4、新增表空间文件

alter tablespace USERS add datafile '/u01/oradata/orcl/users02.dbf' size 4000m autoextend on next 1000m maxsize 12000M;

注:一般新增表空间文件即可。

posted @ 2017-05-12 14:46  AlgorithmInit  阅读(214)  评论(0编辑  收藏  举报