我有這個服務器有以下系統:如何許多SQL查詢結果集成到一個輸出(甲骨文)
的Windows 2003 R2耳鼻喉科版SP 2 甲骨文1.0.2.0.4.0 數據庫:5
這些數據庫的歸檔日誌位於閃回恢復區,如v $ recovery_file_dest的NAME列所示,還可以通過調用sqlplus中的「show parameter db_recovery_file_dest」來進行。我想用SQL或PLSQL腳本來監視每個數據庫的歸檔日誌的空間使用情況。
如果我引用下面的查詢:
SET LINESIZE 145
SET PAGESIZE 9999
COLUMN name FORMAT a30 HEADING 'Name'
COLUMN space_limit FORMAT 99,999,999,999,999 HEADING 'Space Limit'
COLUMN space_used FORMAT 99,999,999,999,999 HEADING 'Space Used'
COLUMN space_used_pct FORMAT 999.99 HEADING '% Used'
COLUMN space_reclaimable FORMAT 99,999,999,999,999 HEADING 'Space Reclaimable'
COLUMN pct_reclaimable FORMAT 999.99 HEADING '% Reclaimable'
COLUMN number_of_files FORMAT 999,999 HEADING 'Number of Files'
prompt
prompt Current location, disk quota, space in use, space reclaimable by deleting files,
prompt and number of files in the Flash Recovery Area.
prompt
SELECT
name
, space_limit
, space_used
, ROUND((space_used/space_limit)*100, 2) space_used_pct
, space_reclaimable
, ROUND((space_reclaimable/space_limit)*100, 2) pct_reclaimable
, number_of_files
FROM
v$recovery_file_dest
ORDER BY
name
/
我會得到這樣的輸出:
Name Space Limit Space Used % Used Space Reclaimable % Reclaimable Number of Files
------------------------------ ------------------- ------------------- ------- ------------------- ------------- ---------------
D:\oracle\product\10.2.0\flash 107,374,182,400 34,239,603,712 31.89 0 .00 804
_recovery_area\DBNAME
我的問題是:我怎麼每個類似的查詢結果整合來自每個數據庫成一個輸出?
輸出應該是這樣的:
Name Space Limit Space Used % Used Space Reclaimable % Reclaimable Number of Files
------------------------------ ------------------- ------------------- ------- ------------------- ------------- ---------------
D:\oracle\product\10.2.0\flash 107,374,182,400 34,239,603,712 31.89 0 .00 804
_recovery_area\DBNAME1
D:\oracle\product\10.2.0\flash 107,374,182,400 34,239,603,712 31.89 0 .00 804
_recovery_area\DBNAME2
D:\oracle\product\10.2.0\flash 107,374,182,400 34,239,603,712 31.89 0 .00 804
_recovery_area\DBNAME3
這涉及到SQL Server,而不是Oracle,所以它可能不一樣 - 但它可能是:如果你知道你的行已經不同了,那就使用UNION ALL。簡單的UNION要求DBMS花費額外的時間去除出現重複行 – RolandTumble 2009-06-03 23:04:55