ITPub博客

首页 > Linux操作系统 > Linux操作系统 > The Power of Inline Views[akadia]

The Power of Inline Views[akadia]

原创 Linux操作系统 作者:jlandzpa 时间:2019-02-19 08:24:04 0 删除 编辑

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


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/936/viewspace-60595/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2001-10-12

  • 博文量
    268
  • 访问量
    170704