Oracle sql union all

來源:互聯網
上載者:User

標籤:

sql union all這個指令的目的也是要將兩個 SQL 陳述式的結果合并在一起。 sql union all和 sql union不同之處在於 sql union all會將每一次合格資料列出來,無論資料庫有無重複。
用法也很簡單:
SELECT top 50 FROM StoreData_200903
UNION ALL
SELECT top 50 FROM StoreData_200904
值得注意的是,sql union all的執行效率要比sql union效率要高很多,這是因為,使用sql union需要進行排重,而sql union All 是不需要排重的,這一點非常重要,因為對於一些單純地使用分表來提高效率的查詢,完全可以使用sql union All。

還有,如果使用了union,無論是sql union還是sql union all一定要記住對資料庫表加上索引!


注意如果使用like等,Regex中可以含有% _ 等簡單的模式,不能包含[]等,如果想使用複雜的Regex,可以使用regexp_like替換like。

regexp_like是一個條件運算式,並不是一個運算子,不能像like那樣使用,要這樣:

where regexp_like(ref, ‘^[1-9]$‘)


like可以這樣用:

where ref like ‘abc_1%‘

原文:http://blog.csdn.net/hongchangfirst/article/details/34073753

作者:hongchangfirst

hongchangfirst的首頁:http://blog.csdn.net/hongchangfirst


Oracle sql union all

聯繫我們

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