ORACLE查看表空间对象
2015-07-02 14:03 潇湘隐者 阅读(17005) 评论(0) 编辑 收藏 举报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
如果你想了解一下对象的详细信息,例如对象类型(表、索引)、对象的OWNER,可以使用下面SQL语句查询
/*查询表空间中对象的详细信息*/
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;
另外,也可以通过下面SQL语句查看表空间的对象
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;
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步