日常维护用到的语句

1140阅读 0评论2015-08-01 cherish568
分类:数据库开发技术

--查看一个表占用多大
select table_name,blocks*8192/1024/1024 size_m from user_tables;
SELECT segment_name AS TABLENAME,BYTES B,BYTES/1024 KB,BYTES/1024/1024 MB FROM user_segments;
--查看表空间使用情况
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;


--查看表空间物理文件的名称及大小 
SELECT tablespace_name,
file_id,
file_name,
round(bytes / (1024 * 1024), 0) total_space
FROM dba_data_files
ORDER BY tablespace_name; 

--查看控制文件
SELECT NAME FROM v$controlfile; 
--5查看日志文件
SELECT MEMBER FROM v$logfile; 
--查看数据库库对象
SELECT owner, object_type, status, COUNT(*) count#
FROM all_objects
GROUP BY owner, object_type, status;
--查看数据库的版本 
SELECT version
FROM product_component_version
WHERE substr(product, 1, 6) = 'Oracle';
--查看数据库的创建日期和归档方式
SELECT created, log_mode, log_mode FROM v$database; 
上一篇:dbms_space解析
下一篇:Oracle闪回查询恢复delete删除数据