The Power of Inline Views[akadia]

A subquery in the FROM clause of a SELECT statement is also called an inline view. When a query contains an inline view, the inline is merged into the query. Powerful constructs can be built using inline views as the next example shows: check the tablespace available, free and used space.

Example

set linesize 100
column file_name format a40 heading "File"
column tablespace_name format a10 heading "Tablespace"
column allocated format 999,999,999 heading "Allocated"
column free format 999,999,999 heading "Free"
column used format 999,999,999 heading "Used"

select a.file_name file_name,
a.tablespace_name tablespace_name,
a.bytes allocated,
nvl(b.free,0) free,
a.bytes-nvl(b.free,0) used
from dba_data_files a, (select file_id, sum(bytes) free
from dba_free_space
group by file_id)
b
where a.file_id = b.file_id (+);

File Tablespace Allocated Free Used
---------------- ---------- ------------ ------------ ------------
ARK1_SYS1.DBF SYSTEM 209,715,200 126,484,480 83,230,720
ARK1_RBS1.DBF RBS 524,353,536 398,458,880 125,894,656
ARK1_USERS1.DBF USERS 94,437,376 58,195,968 36,241,408
ARK1_TAB1.DBF TAB 209,780,736 98,566,144 111,214,592
ARK1_IDX1.DBF IDX 209,780,736 169,345,024 40,435,712
ARK1_OEM1.DBF OEM 524,353,536 356,515,840 167,837,696


请使用浏览器的分享功能分享到微信等