Oralce学习笔记:查询语句 查看数据文件相关信息

■如何查看数据库的各种数据文件?
 1)、查看数据文件
SQL> select file_name,bytes/(1024*1024) m0 from dba_data_files;

2)、查看控制文件
SQL> select NAME,status from v$controlfile;

3)、查看日志文件
SQL> select group#,member,status from v$logfile;

■如何查看各个表空间的自由空间?
SQL> desc dba_free_space
SQL> select tablespace_name,sum(bytes)/1024/1024 free_Mbytes
from dba_free_space
group by tablespace_name
order by free_Mbytes;

■如何查看数据文件所在的路径?
SQL> select tablespace_name,file_id,bytes/1024/1024,file_name
     from dba_data_files order by file_id;

■如何查看数据文件是否自动扩展?
SQL> col FILE_NAME format a40
SQL> col TABLESPACE_NAME format a20
SQL> select file_id,file_name,tablespace_name,autoextensible from dba_data_files order by file_id;

■如何查看各个表空间占用磁盘情况?
SQL> col tablespace format a20
SQL> select 
b.file_id "file_ID",
b.tablespace_name "tablespace_name",
b.bytes "byte_num",
(b.bytes-sum(nvl(a.bytes,0))) "used",
sum(nvl(a.bytes,0)) "remaining_space",
sum(nvl(a.bytes,0))/(b.bytes)*100 "percent" 
from dba_free_space a,dba_data_files b 
where a.file_id=b.file_id 
group by b.tablespace_name,b.file_id,b.bytes 
order by b.file_id;




你可能感兴趣的:(oralce)