Oracle錄屏命令spool的使用

來源:互聯網
上載者:User

標籤:問題 oracle解答

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

最終匯出結果如下:

650) this.width=650;" src="http://note.youdao.com/yws/api/group/11158000/noteresource/AC5C6CE07F194559AD3D8F9CDE0C9AD0/version/22?method=get-resource&shareToken=7D22C6177FCC47A1B64333ACEB68D733&entryId=93917190" style="height:auto;border:0px;" alt="22?method=get-resource&shareToken=7D22C6" />

更多精彩oracle學習資源,盡在我贏職場!

 

http://www.wyzc.com/mysql/?tg=LXUK--Zkf&tg=3006123630

 


Oracle錄屏命令spool的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.