- 論壇徽章:
- 7
|
本帖最后由 aixuexiwoying 于 2016-04-28 11:32 編輯
Oracle錄屏命令spool的使用
SPOOL可以把Oracle客戶端SQLPLUS的輸出導(dǎo)入到一個(gè)文本中,可以導(dǎo)出html、CSV等形式,其語法如下:
spool <filename> [rep/append]
屏幕輸出保留到指定文件中,如果文件存在想替換內(nèi)容使用replace,追加內(nèi)容到文件中使用append
關(guān)閉并把輸出發(fā)送到系統(tǒng)打印機(jī)打印用spool out,不過這個(gè)命令在某些系統(tǒng)不能用
關(guān)閉屏幕內(nèi)容輸出到文件使用spool off
比如我們想要把Oracle各表空間的使用情況輸出為HTML格式的報(bào)表:
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
最終導(dǎo)出結(jié)果如下:
1460536000384.jpg (18.94 KB, 下載次數(shù): 55)
下載附件
2016-04-28 11:29 上傳
歡迎大家溝通學(xué)習(xí)。!
更多精彩內(nèi)容:
我贏職場(chǎng)二維.png (14.31 KB, 下載次數(shù): 47)
下載附件
2016-04-28 11:30 上傳
|
|