本文共 1171 字,大约阅读时间需要 3 分钟。
ORACLE如何查看表空间存储了那些数据库对象呢?可以使用下面脚本简单的查询表空间存储了那些对象:
SELECT TABLESPACE_NAME AS TABLESPACE_NAME
, SEGMENT_NAME AS SEGMENT_NAME
, SUM(BYTES)/1024/1024 AS SEGMENT_SIZE
FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME=&TABLESPACE_NAME
GROUP BY TABLESPACE_NAME,SEGMENT_NAME
ORDER BY 3
/*查询表空间中对象的详细信息*/
SELECT OWNER AS OWNER
,SEGMENT_NAME AS SEGMENT_NAME
,SEGMENT_TYPE AS SEGMENT_TYPE
,SUM(BYTES)/1024/1024 AS SEGMENT_SIZE
FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME=&TABLESPACE_NAME
GROUP BY OWNER,SEGMENT_NAME,SEGMENT_TYPE
ORDER BY 4;
SELECT OWNER AS OWNER
,'TABLE' AS SEGMENT_TYPE
,TABLE_NAME AS SEGMENT_NAME
FROM DBA_TABLES
WHERE TABLESPACE_NAME=&TABLESPACE_NAME
UNION ALL
SELECT OWNER AS OWNER
,'INDEX' AS SEGMENT_TYPE
,INDEX_NAME AS SEGMETN_NAME
FROM DBA_INDEXES
WHERE TABLESPACE_NAME=&TABLESPACE_NAME
UNION ALL
SELECT OWNER AS OWNER
,'LOBSEGMENT' AS SGEMENT_TYPE
,SEGMENT_NAME AS SEGMENT_NAME
FROM DBA_LOBS
WHERE TABLESPACE_NAME=&TABLESPACE_NAME;
转载地址:http://hygxx.baihongyu.com/