oracle表空间相关SQL语句
2015-08-21 22:43
537 查看
Oracle 数据库查看表空间的使用情况
SELECT d.tablespace_name, space "SUM_SPACE(MB)", space - NVL(free_space, 0) "USED_SPACE(MB)", free_space "FREE_SPACE(MB)", ROUND((1 - NVL(free_space, 0) / space) * 100, 2) "USED_RATE(%)", ROUND(NVL(free_space, 0) * 100 / space, 2) "FREE_RATE(%)" FROM (SELECT tablespace_name, ROUND(SUM(bytes) / (1024 * 1024), 2) space FROM dba_data_files GROUP BY tablespace_name) d, (SELECT tablespace_name, ROUND(SUM(bytes) / (1024 * 1024), 2) free_space FROM dba_free_space GROUP BY tablespace_name) f WHERE d.tablespace_name = f.tablespace_name(+) ORDER BY "USED_RATE(%)" DESC;
查看表空间的数据文件
select t1.name, t2.name from v$tablespace t1, v$datafile t2 where t1.ts# = t2.ts# and t1.name = 'tablespace_Name'
查看表空间的详细情况
SELECT t.tablespace_name, 'Datafile' file_type, t.status tablespace_status, d.status file_status, ROUND((d.bytes - NVL(f.sum_bytes, 0)) / 1048576) used_mb, ROUND(NVL(f.sum_bytes, 0) / 1048576) free_mb, t.initial_extent, t.next_extent, t.min_extents, t.max_extents, t.pct_increase, d.file_name, d.file_id, d.autoextensible, d.maxblocks, d.maxbytes, nvl(d.increment_by, 0) increment_by, t.block_size FROM (SELECT tablespace_name, file_id, SUM(bytes) sum_bytes FROM DBA_FREE_SPACE GROUP BY tablespace_name, file_id) f, DBA_DATA_FILES d, DBA_TABLESPACES t WHERE t.tablespace_name = d.tablespace_name AND f.tablespace_name(+) = d.tablespace_name AND f.file_id(+) = d.file_id GROUP BY t.tablespace_name, d.file_name, d.file_id, t.initial_extent, t.next_extent, t.min_extents, t.max_extents, t.pct_increase, t.status, d.bytes, f.sum_bytes, d.status, d.AutoExtensible, d.maxblocks, d.maxbytes, d.increment_by, t.block_size UNION ALL SELECT h.tablespace_name, 'Tempfile', ts.status, t.status, ROUND(SUM(NVL(p.bytes_used, 0)) / 1048576), ROUND(SUM((h.bytes_free + h.bytes_used) - NVL(p.bytes_used, 0)) / 1048576), -1, -- initial extent -1, -- initial extent -1, -- min extents -1, -- max extents -1, -- pct increase t.file_name, t.file_id, t.autoextensible, t.maxblocks, t.maxbytes, nvl(t.increment_by, 0) increment_by, ts.block_size FROM sys.V_$TEMP_SPACE_HEADER h, sys.V_$TEMP_EXTENT_POOL p, sys.DBA_TEMP_FILES t, sys.dba_tablespaces ts WHERE p.file_id(+) = h.file_id AND p.tablespace_name(+) = h.tablespace_name AND h.file_id = t.file_id AND h.tablespace_name = t.tablespace_name and ts.tablespace_name = h.tablespace_name GROUP BY h.tablespace_name, t.status, t.file_name, t.file_id, ts.status, t.autoextensible, t.maxblocks, t.maxbytes, t.increment_by, ts.block_size ORDER BY 1, 5 DESC
查看表空间是否可扩展
select file_name,autoextensible,increment_by from dba_data_files;
查看表空间的创建语句
SELECT tablespace_name, DBMS_METADATA.GET_DDL('TABLESPACE', TS.tablespace_name) FROM DBA_TABLESPACES TS;
查看存储过程方法等的创建语句
select * from dba_source
相关文章推荐
- Oracle 学习之 11g Clone 安装
- oracle SQL高级编程
- Oracle 学习之卸载Oracle 11g
- VS报错:Oracle.ManagedDataAccess.Client.OracleException: ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值
- oracle12创建用户授权和密码报:65096 公用用户名或角色无效
- Centos中将openjdk切换为Oracle Jdk导致Tomcat无法正常启动的问题
- Oracle关于时间/日期的操作
- Oracle11g透明网关搭建
- Oracle 11g导出的dmp文件导入到10g
- qt编译oracle插件驱动
- Oracle 动态SQL实现SQL查询子集行转列
- powerdesigner jdbc 连接 oracle
- IE访问Oracle EBS打不开Form的问题
- oracle not in 查不出数据
- oracle中的正则表达式
- 关于Oracle ADF 11g的传值给bounded task flow(二)
- Oracle 把字符串分割后保存到Table的一个字段中
- oracle安装后,启动项设置和登录问题
- 登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting
- 将字符和数字分离