1.查看所有表空间大小
1 select tablespace_name,sum(bytes)/1024/1024 from dba_data_files
2 group by tablespace_name;
2. 未使用的表空间大小
1 select tablespace_name,sum(bytes)/1024/1024 from dba_free_space
2 group by tablespace_name;
2 group by tablespace_name;
3. 所以使用空间可以这样计算
1 select a.tablespace_name,total,free,total-free used from
2 (select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
3 group by tablespace_name) a,
4 (select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
5 group by tablespace_name) b
6 where a.tablespace_name=b.tablespace_name;
2 (select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
3 group by tablespace_name) a,
4 (select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
5 group by tablespace_name) b
6 where a.tablespace_name=b.tablespace_name;
4. 下面这条语句查看所有segment的大小
1 Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name
5. 还有在命令行情况下如何将结果放到一个文件里
1 SQL> spool out.txt
2 SQL> select * from v$database;
3 SQL> spool off
2 SQL> select * from v$database;
3 SQL> spool off
6.如何查看oracle临时表空间当前使用了多少空间的大小?
不是占用量,是当前正在使用的临时表空间大小
1 SELECT SE.USERNAME,
2 SE.SID,
3 SU.EXTENTS,
4 SU.BLOCKS * TO_NUMBER(RTRIM(P.VALUE)) AS SPACE,
5 TABLESPACE,
6 SEGTYPE,
7 SQL_TEXT
8 FROM V$SORT_USAGE SU, V$PARAMETER P, V$SESSION SE, V$SQL S
9 WHERE P.NAME = 'db_block_size'
10 AND SU.SESSION_ADDR = SE.SADDR
11 AND S.HASH_VALUE = SU.SQLHASH
12 AND S.ADDRESS = SU.SQLADDR
13 ORDER BY SE.USERNAME, SE.SID;
2 SE.SID,
3 SU.EXTENTS,
4 SU.BLOCKS * TO_NUMBER(RTRIM(P.VALUE)) AS SPACE,
5 TABLESPACE,
6 SEGTYPE,
7 SQL_TEXT
8 FROM V$SORT_USAGE SU, V$PARAMETER P, V$SESSION SE, V$SQL S
9 WHERE P.NAME = 'db_block_size'
10 AND SU.SESSION_ADDR = SE.SADDR
11 AND S.HASH_VALUE = SU.SQLHASH
12 AND S.ADDRESS = SU.SQLADDR
13 ORDER BY SE.USERNAME, SE.SID;
查询所有的表空间
1 select tablespace_name from dba_tablespaces