連線操作 Oracle 學習筆記 3

2021-04-15 12:11:30 字數 498 閱讀 7000

以前在學資料庫時 就沒搞明白什麼是外連線,今天才弄明白~   o(∩_∩)o   我是不是很笨~...

select *

from table1,table2

這裡from子句的兩個表執行的是笛卡爾積操作。也就是table2中的所有記錄從頭到尾吧table1中的所有記錄對映一遍。得到的記錄數是兩個表記錄數的乘積。

select *

from table1 a, table2 b

where a.id=b.id

這裡加上了where子句,得出的結果是兩個表id欄位相等的記錄。也就是說兩個表都可能會有記錄不會被查詢到。

select *

from table1 a, table2 b

where a.id=b.id (+)

這裡where子句條件後面加上了(+)。其中沒有(+)的表是驅動表(table1)。查詢結果將會包含驅動表的所有記錄,不管是否能和table2匹配。而table2只有和驅動表匹配的記錄才會被查詢到。

oracle學習筆記3

1.子查詢 select ename,sal,deptno from emp where sal in select max sal from emp group by deptno 求在不同部門薪水最高的雇員的資訊 錯誤!因為查詢的結果是工資是在所有部門下的最高工資範圍中,就是說存在一種結果 同一...

oracle學習筆記 3

生成表 臨時表,存在於事務範圍或會話範圍,供全體使用者使用 create global temporary table temp emp empno number,ename varchar2 10 create table emp copy as select from emp where dep...

oracle學習筆記(3)

使用profile檔案對口令進行管理 sql create profile 檔名 limit failed login arrempts 3 password lock time 2 將配之檔案分配給使用者 sql alter user 使用者名稱 profile 檔名 給賬戶解鎖 sql alte...