Oracle聯合查詢

2022-03-29 02:37:50 字數 634 閱讀 6596

select * from teacher

--聯合查詢

--01.union (並集)

select tno from teacher where tno>1080 union

(select tno from teacher where tno>1090)

--02.union all(並集並且顯示重複的資料)

select tno from teacher where tno>1080 union all

(select tno from teacher where tno>1090)

--03.minus(補集) a minus b a-b相當於去掉重複的資料 確保a的返回大於b的範圍

select tno from teacher where tno>1080 minus

(select tno from teacher where tno>1090)

--04.intersect(交集) 只查詢重複的資料

select tno from teacher where tno>1080 intersect

(select tno from teacher where tno>1090)

(以上內容來自王碩老師)

oracle多表聯合查詢加gruop by處理

oracle資料庫中多表聯合查詢,獲取gruop by後的結果,結果包含兩表資料 例如 表a 中 a.a欄位關聯表b字典中b.b欄位,獲取a.a欄位的gruop by 和b.a欄位 專案中sql如下select a.provide dep id count a.provide dep id b.st...

oracle(15) SQL 多表聯合查詢

外連線 左右連線 左右連線 範例 查詢出每乙個部門的員工 範例 左連線 範例 右連線 範例 查詢出所有員工的上級領導 以上操作完整原始碼 查詢所有部門 select from dept d 查詢所有部門下的員工 select from emp e order by deptno 查詢員工 部門資訊 ...

Oracle聯合索引

oracle 聯合索引 我現在用的是oracle 9i 1.乙個表建立多少個索引比較合適?比如說不大於5個 這個沒有定論,樓主要綜合查詢效率和dml效率自己確定,索引可以加快select的查詢速度,但也會降低delete,insert和update等dml語句的執行速度。2.聯合索引比單索引的效率高...