ORACLE数据库、表空间、表的容量相关查询--1
ORACLE数据库、表空间、表的容量相关查询--11.查询某个表所占空间大小col tablespace_name for a15col segment_name for a15col segment_type for a15select segment_name,segment_type,tablespace_name,extents,bytes/1024 KB from dba_segments where segment_name like 'TEST%';结果如下:SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME EXTENTS KB--------------- --------------- --------------- ---------- ----------TEST TABLE USERS 1 64TEST1 TABLE USERS 1 64TEST1 TABLE USERS 168 794624TEST5 TABLE RMANTEST 1 64TEST9 TABLE USERS 169 8007683.某个用户下的表所占空间前三位:select * from (select segment_name,bytes/1024 KB from dba_segments where owner = 'BYS' order by bytes desc ) where rownum <= 3;SEGMENT_NAME KB--------------- ----------TEST9 800768TEST1 794624EMP 64用SQL计算出某个用户下所有对象的大小,给出SQL语句和结果。SQL> show userUser is "bys"SQL> select sum(a.m) from (select segment_name,segment_type,bytes/1024/1024 M from user_segments) a;SUM(A.M)----------42.查询表空间大小及空闲空间大小,使用率等主要使用的视图有:dba_data_files,dba_free_spacecol used_% for a8select df.tablespace_name,df.sum_df_m as space_m,df.sum_df_m-fs.sum_fs_m as used_m,fs.sum_fs_m as free_space,to_char(trunc((df.sum_df_m-fs.sum_fs_m)/df.sum_df_m,2)*100) as "used_%" from (select tablespace_name,sum(bytes/1024/1024) as sum_df_m from dba_data_files group by tablespace_name) df,(select tablespace_name,sum(bytes/1024/1024) as sum_fs_m from dba_free_space group by tablespace_name) fs where df.tablespace_name=fs.tablespace_name;结果如下:TABLESPACE_NAME SPACE_M USED_M FREE_SPACE used_%--------------- ---------- ---------- ---------- --------SYSAUX 670 637.125 32.875 95UNDOTBS1 125 30.125 94.875 24RMANTEST 10 1.0625 8.9375 10USERS 1703.75 1562.5 141.25 91SYSTEM 700 692.3125 7.6875 98EXAMPLE 100 79.25 20.75 79select df.tablespace_name,df.sum_df_m as space_m,df.sum_df_m-fs.sum_fs_m as used_m,fs.sum_fs_m as free_space,to_char(trunc((df.sum_df_m-fs.sum_fs_m)/df.sum_df_m,2)*100) as "used_%" from (select tablespace_name,sum(bytes/1024/1024) as sum_df_m from dba_data_files group by tablespace_name) df,(select tablespace_name,sum(bytes/1024/1024) as sum_fs_m from dba_free_space group by tablespace_name) fs where df.tablespace_name=fs.tablespace_name and df.tablespace_name='USERS';结果如下:TABLESPACE_NAME SPACE_M USED_M FREE_SPACE used_%--------------- ---------- ---------- ---------- --------USERS 1703.75 1562.5 141.25 91.用SQL计算某个表空间所包含对象的大小SQL> show userUser is "bys"SQL> select 'SIZE_TABELSPACE' NAME,sum(user_bytes)/1024/1024 SIZE_M from dba_data_files where tablespace_name='USERS' UNION ALL select 'SIZE_OBJECT' NAME,sum(nvl(bytes,0))/1024/1024 SIZE_M from user_segments where tablespace_name='USERS';NAME SIZE_M--------------- ----------SIZE_TABELSPACE 5.25SIZE_OBJECT 43.查询数据文件大小及文件名col file_name for a35select file_name,file_id,tablespace_name,bytes/1024/1024 MB from dba_data_files;FILE_NAME FILE_ID TABLESPACE_NAME MB----------------------------------- ---------- --------------- ----------/u01/oradata/bys1/users01.dbf 4 USERS 1703.75/u01/oradata/bys1/undotbs01.dbf 3 UNDOTBS1 125/u01/oradata/bys1/sysaux01.dbf 2 SYSAUX 670/u01/oradata/bys1/system01.dbf 1 SYSTEM 700/u01/oradata/bys1/example01.dbf 5 EXAMPLE 100/u01/oradata/bys1/rmantest.dbf 6 RMANTEST 104.查询整个数据库的容量数据文件大小select sum(m) as sum_d from (select file_name,tablespace_name,bytes/1024/1024 m from dba_data_files union select file_name,tablespace_name,bytes/1024/1024 m from dba_temp_files);重做日志文件大小select sum(a.members*a.m) as sum_r from (select group#,members,bytes/1024/1024 m from v$log) a;控制文件大小SQL> select sum(bytes_m) as sum_c from (select name,block_size*file_size_blks/1024/1024 as bytes_m from v$controlfile);数据库总容量:SQL> select sum_d+sum_r+sum_c as sum_database_M,sum_d as sum_datafile,sum_r as sum_redo,sum_c as sum_ctl from (select sum(m) as sum_d from (select file_name,tablespace_name,bytes/1024/1024 m from dba_data_files union select file_name,tablespace_name,bytes/1024/1024 m from dba_temp_files)) a,(select sum(members*m) as sum_r from (select group#,members,bytes/1024/1024 m from v$log)) b,(select sum(bytes_m) as sum_c from (select name,block_size*file上一个:打开SQLPLUS中执行计划的各种参数
下一个:如何诊断job执行失败
- 更多Oracle疑问解答:
- 运行exp备份oracle数据库提示oracle-12154错误
- 有没有,生产Oracle Rman 备份脚本的工具啊!
- 初学orcle,希望有大大帮忙解说一下详细步骤,从登录oracle到创建表的过程
- oracle语句问题:一张user表,三个字段,id,name,time,插入记录比如:张三2007,李四2008,张三2011
- 如何写一个ORACLE触发器同步两个表中的数据?
- oracle 如何查看一个服务器上有多少个数据库.
- oracle 创建包的时候错误 求解
- oracle 重复列的问题
- oracle 中如何查处2星期前的数据
- 请教oracle数据库安装中的问题
- 请问谁能提供给我标准的oracle ERP的数据库表结构并详细说明各表主要的作用?
- 安装oracle遇到的问题 invalid entry CRC (expected 0x3e12e795 but got 0x9db0e9fd)
- 我的是ORACLE 10G,在RMAN中如何按指定的时间恢复数据文件啊?
- oracle为什么没有自动增长列
- oracle快捷键都有哪些啊?