ORACLE with..as...語句

來源:互聯網
上載者:User

標籤:oracle   with...as...   

       with...as ...語句用於將查詢語句定義為某個名稱,並可以再後續的查詢塊中引用。當查詢名稱與已有的表名重複時,with定義的查詢塊優先順序高。with語句可以定義多個查詢,中間使用逗號分隔。常用於定於需要反覆查詢某些表的視圖中,使用with語句把需要查詢的表定義為查詢快再使用比直接在視圖中反覆的查詢表效率要高一些。個人覺得with..as..的作用是把會反覆使用的表欄位在查詢塊中預先查詢出來,為這個查詢塊定義一個名稱,作用類似於一個暫存資料表。

  例子:

 create or replace view test_with_as as  --定義with..as..查詢塊 with      dept_info  as (select dept_name,dept_id  from dept), employee_info as (select  employee_name, employee_id, dept_id, salary   from employee) --調用with..as..中的查詢塊 select d.*,t.* from dept_info  d  inner join employee_info  e on d.dept_id=e.dept_id;

本文出自 “天黑順路” 部落格,請務必保留此出處http://mjal01.blog.51cto.com/12140495/1975519

ORACLE with..as...語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.