經常在工作中用到,雖然當年在數據庫原理課程中學習過,不過基本已經還給老師了。工作這麼多年,感覺自己在學習上倒退了很多,慚愧。這篇帖子,作爲SQL相關知識的整理貼。
1、semi-join(半連接)(來自:http://wiki.answers.com/Q/What_is_semi_join_in_SQL)
半連接返回表中能夠與另一表中連接的記錄(並不執行一次全連接),它並沒有一個明確的語法格式。
A semi-join returns rows from one table that would join with another table without performing a complete join. It doesn't have explicit syntax.
例子,從表Customers中選擇其ID出現在表Sales中的客戶的ID和Name:
select *
from Customers C
where exists (
select *
from Sales S
where S.Cust_Id = C.Cust_Id
)
Cust_Id Cust_Name
----------- ----------
2 John Doe
3 Jane Doe
來看看這篇文章:http://blog.csdn.net/tiwen818/article/details/7103711,比較詳細的介紹了Oracle中的半連接。慚愧啊,話說這個帖子裏面的這個語句我就沒看懂:
create table table_1
as select
cast(rownum as int) a,
cast(rownum+10 as int) b,
cast(dbms_random.string('i',10) as varchar2(10)) c
from dual connect by level<=500000
看了這篇文章http://yesican.blog.51cto.com/700694/269814和這篇http://www.360doc.com/content/13/0422/16/11947209_280153192.shtml才明白。
2、join(連接)(來自:http://www.w3schools.com/sql/sql_join.asp)
總共有四種連接類型:
內連接:http://www.w3schools.com/sql/sql_join_inner.asp
全連接:http://www.w3schools.com/sql/sql_join_full.asp
左連接:http://www.w3schools.com/sql/sql_join_left.asp
右連接:http://www.w3schools.com/sql/sql_join_right.asp
3、aggregation(聚合)(來自:http://msdn.microsoft.com/zh-cn/library/ms173454.aspx)
聚合函數對一組值執行計算,並返回單個值。 除了 COUNT 以外,聚合函數都會忽略空值。 聚合函數經常與 SELECT 語句的 GROUP BY 子句一起使用。