用SQLPLUS以指定格式輸出表中的資料到文字檔案

2021-08-22 02:00:35 字數 544 閱讀 6370

--用sqlplus以指定格式輸出表中的資料到文字檔案

set term off --去掉螢幕顯示

set feed off --去掉顯示輸出的行數

set pagesize 0 --不換頁

set linesize 2000 --設定行的長度,保證能夠顯示輸出的所有的字段長度的和

set space off --設定輸出列間空格數

set trims on --去掉尾端空格

spool e:\x.txt

select sysdate||chr(9)||table_name||chr(9)||tablespace_name||chr(9)||cluster_name||chr(9)||iot_name||chr(9)||pct_free||chr(9)||pct_used||chr(9)||duration||chr(9)||skip_corrupt||chr(9)||monitoring||chr(9)||cluster_owner from user_tables;

spool off

exit

printf輸出指定格式

參考部落格 printf格式輸出 flags width perc f n h l type 用到了flags中的 0 注意是零不是歐 其百科描述為 將輸出的前面補上0,直到佔滿指定列寬為止 不可以搭配使用 width 即表示需要輸出的位數。int a 4 printf 03d a 輸出 004 也...

輸出指定格式的日期。

程式分析 使用 datetime 模組。if name main pass code codec n input input the number n code.scoreofstudent n 輸出今日日期,格式為 dd mm yyyy。更多選項可以檢視 strftime 方法 print dat...

學習筆記 XSLT輸出指定格式

qname but not ncname version nmtoken encoding string omit xml declaration yes no standalone yes no doctype public string doctype system string cdata s...