oracle查看表空间的大小及使用情况sql语句
发布时间:2020-12-12 13:37:59 所属栏目:百科 来源:网络整理
导读:? --------------------------tablespace-------------------------------- 1 、 // 查看表空间的名称及大小 SELECT t.tablespace_name,round(SUM(bytes / ( 1024 * 1024 )), 0 ) ts_size FROM dba_tablespaces t,dba_data_files d WHERE t.tablespace_name
? --------------------------tablespace-------------------------------- 1、//查看表空间的名称及大小 SELECT t.tablespace_name,round(SUM(bytes / (1024 * 1024)),0) ts_size FROM dba_tablespaces t,dba_data_files d WHERE t.tablespace_name = d.tablespace_name GROUP BY t.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、//查看回滚段名称及大小 SELECT segment_name,tablespace_name,r.status,(initial_extent / 1024) initialextent,(next_extent / 1024) nextextent,max_extents,v.curext curextent FROM dba_rollback_segs r,v$rollstat v WHERE r.segment_id = v.usn(+) ORDER BY segment_name; ? --------------------------tablespace使用大小计算------------------------------- 1G=1024MB 1M=1024KB 1K=1024Bytes 1M=11048576Bytes 1G=1024*11048576Bytes=11313741824Bytes 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 ? ?-----------------------------扩增表空间大小--------- //查询用户对应的表空间,我们可以看到针对不同的数据库用户ORACLE select username,default_tablespace,temporary_tablespace from dba_users; //查询用户的对应的数据文件,以及数据文件大小 select tablespace_name,round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name; //扩增表空间大小 alter database datafile ‘/data/URSP_SLSADMIN.dbf‘ resize 6000M (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |