1. 程式人生 > >union 與union all的區別

union 與union all的區別

union 在進行錶鏈接後會篩選掉重複的記錄,所以在錶鏈接後會對所產生的結果集進行排 序運算,刪除重複的記錄再返回結果。

union all 則會顯示重複結果,只是簡單的兩個結果合併並返回.所以效率比union高,在保證沒有重複資料的情況下用union all.