免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1337 | 回复: 0

[讨论] Oracle初学者快来看,教会你什么是真正的录屏命令。。 [复制链接]

论坛徽章:
7
数据库技术版块每日发帖之星
日期:2016-04-26 06:20:00数据库技术版块每日发帖之星
日期:2016-05-01 06:20:00数据库技术版块每日发帖之星
日期:2016-05-02 06:20:00数据库技术版块每日发帖之星
日期:2016-05-06 06:20:00数据库技术版块每日发帖之星
日期:2016-05-07 06:20:00数据库技术版块每日发帖之星
日期:2016-05-08 06:20:00数据库技术版块每日发帖之星
日期:2016-05-17 06:20:00
发表于 2016-04-28 11:31 |显示全部楼层
本帖最后由 aixuexiwoying 于 2016-04-28 11:32 编辑

Oracle录屏命令spool的使用


SPOOL可以把Oracle客户端SQLPLUS的输出导入到一个文本中,可以导出html、CSV等形式,其语法如下:

spool <filename> [rep/append]

屏幕输出保留到指定文件中,如果文件存在想替换内容使用replace,追加内容到文件中使用append

关闭并把输出发送到系统打印机打印用spool out,不过这个命令在某些系统不能用

关闭屏幕内容输出到文件使用spool off

比如我们想要把Oracle各表空间的使用情况输出为HTML格式的报表:

SET MARKUP HTML ON SPOOL ON pre off entmap off

SET ECHO OFF

SET TERMOUT OFF

SET TRIMOUT OFF

set feedback off

set heading on

set linesize 200

set pagesize 10000

col tablespace_name format a15

col total_space format a10

col free_space format a10

col used_space format a10

col used_rate format 99.99

spool /home/oracle/test.html

select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m'

free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,

(1-(b.free_space_Mb/a.total_space_Mb))*100 used_rate,a.total_blocks,b.free_blocks from

(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files

group by tablespace_name) a,

(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space

group by tablespace_name) b

where a.tablespace_name=b.tablespace_name order by used_rate desc;

spool off


最终导出结果如下:

1460536000384.jpg

欢迎大家沟通学习!!!

更多精彩内容:

我赢职场二维.png
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP