詳解 SQL 的集合運算

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"你好,我是 悟空。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"概述:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本篇主要是對集合運算中並集、交集、差集運算基礎的總結。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"集合運算包含三種:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.並集運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.交集運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.差集運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面是集合運算的思維導圖:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9c/9c1cb7111ce1dde995f42945d3bd11ba.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"爲什麼使用集合運算:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.在集合運算中比聯接查詢和EXISTS/NOT EXISTS更方便。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在閱讀下面的章節時,我們可以先把環境準備好,以下的SQL腳本可以幫助大家創建數據庫,創建表,插入數據。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下載腳本文件:","attrs":{}},{"type":"link","attrs":{"href":"http://files.cnblogs.com/files/jackson0714/TSQLFundamentals2008.zip","title":"","type":null},"content":[{"type":"text","text":"TSQLFundamentals2008.zip","attrs":{}}]}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"一、集合運算","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1.集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)對輸入的兩個集合或多集進行的運算。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)多集:由兩個輸入的查詢生成的可能包含重複記錄的中間結果集。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)T-SQL支持三種集合運算:並集(UNION)、交集(INTERSECT)、差集(EXCEPT)","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2.語法","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"集合運算的基本格式:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"輸入的查詢1","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"輸入的查詢2","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"[ORDER BY]","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3.要求","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)輸入的查詢不能包含ORDER BY字句;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)可以爲整個集合運算結果選擇性地增加一個ORDER BY字句;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)每個單獨的查詢可以包含所有邏輯查詢處理階段(處理控制排列順序的ORDER BY字句);","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(4)兩個查詢 必須包含相同的列數;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(5)相應列必須具有兼容的數據類型。兼容個的數據類型:優先級較低的數據類型必須能隱式地轉換爲較高級的數據類型。比如輸入的查詢1的第一列爲int類型,輸入的查詢2的第一列爲float類型,則較低的數據類型int類型可以隱式地轉換爲較高級float類型。如果輸入的查詢1的第一列爲char類型,輸入的查詢2的第一列爲datetime類型,則會提示轉換失敗:從字符串轉換日期和/或時間時,轉換失敗;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(6)集合運算結果中列名由輸入的查詢1決定,如果要爲結果分配結果列,應該在輸入的查詢1中分配相應的別名;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(7)集合運算時,對行進行進行比較時,集合運算認爲兩個NULL相等;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(8)UNION支持DISTINCT和ALL。不能顯示指定DISTINCT字句,如果不指定ALL,則默認使用DISTINCT;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(9)INTERSET和EXCEPT默認使用DISTINCT,不支持ALL。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"二、UNION(並集)集合運算","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1.並集的文氏圖","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"並集:兩個集合的並集是一個包含集合A和B中所有元素的集合。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"圖中陰影區域代表集合A與集合B的並集","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/55/55c5032e741cab6e0ecc17ad24457ffb.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2.UNION ALL集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)假設Query1返回m行,Query2返回n行,則Query1 UNION ALL Query2返回(m+n)行;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)UNION ALL 不會刪除重複行,所以它的結果就是多集,而不是真正的集合;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)相同的行在結果中可能出現多次。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3.UNION DISTINCT集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)假設Query1返回m行,Query2返回n行,Query1和Query2有相同的h行,則Query1 UNION Query2返回(m+n-h)行;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)UNION 會刪除重複行,所以它的結果就是集合;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)相同的行在結果中只出現一次。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(4)不能顯示指定DISTINCT字句,如果不指定ALL,則默認使用DISTINCT。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(5)當Query1與Query2比較某行記錄是否相等時,會認爲取值爲NULL的列是相等的列。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"三、INTERSECT(交集)集合運算","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1.交集的文氏圖","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"交集:兩個集合(記爲集合A和集合B)的交集是由既屬於A,也屬於B的所有元素組成的集合。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"圖中陰影區域代表集合A與集合B的交集","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/7b/7bd2c3e7695381f2ca033147ae1815e4.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2.INTERSECT DISTINCT集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)假設Query1返回 m 行,Query2返回 n 行,Query1和Query2有相同的 h 行,則Query1 INTERSECT Query2返回 h 行;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)INTERSECT集合運算在邏輯上首先刪除兩個輸入多集中的重複行(把多集變爲集合),然後返回只在兩個集合中都出現的行;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)INTERSECT 會刪除重複行,所以它的結果就是集合;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(4)相同的行在結果中只出現一次。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(5)不能顯示指定DISTINCT字句,如果不指定ALL,則默認使用DISTINCT。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(6)當Query1與Query2比較某行記錄是否相等時,會認爲取值爲NULL的列是相等的列。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(7)用內聯接或EXISTS謂詞可以代替INTERSECT集合運算,但是必須對NULL進行處理,否則這兩種方法對NULL值進行比較時,比較結果都是UNKNOWN,這樣的行會被過濾掉。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3.INTERSECT ALL集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)ANSI SQL支持帶有ALL選項的INTERSECT集合運算,但SQL Server2008現在還沒有實現這種運算。後面會提供一種用於T-SQL實現的替代方案;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)假設Query1返回 m 行,Query2返回 n 行,如果行R在Query1中出現了x次,在Query2中出現了y次,則行R應該在INTERSECT ALL運算之後出現minimum(x,y)次。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面提供用於T-SQL實現的INTERSECT ALL集合運算:公用表表達式 + 排名函數","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"WITH INTERSECT_ALL\n AS ( \n SELECT ROW_NUMBER() OVER ( PARTITION BY country, region, city ORDER BY ( SELECT\n 0\n ) ) AS rownum ,\n country ,\n region ,\n city\n FROM HR.Employees\n INTERSECT\n SELECT ROW_NUMBER() OVER ( PARTITION BY country, region, city ORDER BY ( SELECT\n 0\n ) ) AS rownum ,\n country ,\n region ,\n city\n FROM Sales.Customers\n )\n SELECT country ,\n region ,\n city\n FROM INTERSECT_ALL\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"結果如下:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/5b/5bb892d4dc63dce59247caaf43e58741.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其中UK NULL London有四個重複行,","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在排序函數的OVER字句中使用 ORDER BY ( SELECT )可以告訴SQL Server不必在意行的順序。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"四、EXCEPT(差集)集合運算","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1.差集的文氏圖","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"差集:兩個集合(記爲集合A和集合B)的由屬於集合A,但不屬於集合B的所有元素組成的集合。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"圖中陰影區域代表集合A與集合B的差集","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/f8/f88252f091d3b22ea12de5aec5575a59.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2.EXCEPT DISTINCT集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)假設Query1返回 m 行,Query2返回 n 行,Query1和Query2有相同的 h 行,則Query1 INTERSECT Query2返回 m - h 行,而Query2 INTERSECT Query1 返回 n - h 行","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)EXCEPT集合運算在邏輯上先刪除兩個輸入多集中的重複行(把多集轉變成集合),然後返回只在第一個集合中出現,在第二個集合衆不出現所有行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)EXCEPT 會刪除重複行,所以它的結果就是集合;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(4)EXCEPT是不對稱的,差集的結果取決於兩個查詢的前後關係。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(5)相同的行在結果中只出現一次。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(6)不能顯示指定DISTINCT字句,如果不指定ALL,則默認使用DISTINCT。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(7)當Query1與Query2比較某行記錄是否相等時,會認爲取值爲NULL的列是相等的列。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(8)用左外聯接或NOT EXISTS謂詞可以代替INTERSECT集合運算,但是必須對NULL進行處理,否則這兩種方法對NULL值進行比較時,比較結果都是UNKNOWN,這樣的行會被過濾掉。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3.EXCEPT ALL集合運算","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)ANSI SQL支持帶有ALL選項的EXCEPT集合運算,但SQL Server2008現在還沒有實現這種運算。後面會提供一種用於T-SQL實現的替代方案;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)假設Query1返回 m 行,Query2返回 n 行,如果行R在Query1中出現了x次,在Query2中出現了y次,且x>y,則行R應該在EXCEPT ALL運算之後出現 x - y 次。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下面提供用於T-SQL實現的EXCEPT ALL集合運算:公用表表達式 + 排名函數","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"WITH INTERSECT_ALL\n AS ( \n         SELECT ROW_NUMBER() OVER ( PARTITION BY country, region, city ORDER BY ( SELECT\n 0\n ) ) AS rownum ,\n country ,\n region ,\n city\n FROM HR.Employees\n EXCEPT\n SELECT ROW_NUMBER() OVER ( PARTITION BY country, region, city ORDER BY ( SELECT\n 0\n ) ) AS rownum ,\n country ,\n region ,\n city\n FROM Sales.Customers\n )\n SELECT country ,\n region ,\n city\n FROM INTERSECT_ALL\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"結果如下:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/f5/f5c6221e485649c39b99a2f5932442ae.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"五、集合運算的優先級","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.INTERSECT>UNION=EXCEPT","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.首先計算INTERSECT,然後從左到右的出現順序依次處理優先級的相同的運算。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.可以使用圓括號控制集合運算的優先級,它具有最高的優先級。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"六、特殊處理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.只有ORDER BY能夠直接應用於集合運算的結果;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.其他階段如表運算符、WHERE、GROUP BY、HAVING等,不支持直接應用於集合運算的結果,這個時候可以使用表表達式來避開這一限制。如根據包含集合運算的查詢定義個表表達式,然後在外部查詢中對錶表達式應用任何需要的邏輯查詢處理;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.ORDER BY字句不能直接應用於集合運算中的單個查詢,這個時候可以TOP+ORDER BY字句+表表達式來避開這一限制。如定義一個基於該TOP查詢的表表達式,然後通過一個使用這個表表達式的外部查詢參與集合運算。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"七、練習題","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"1.寫一個查詢,返回在2008年1月有訂單活動,而在2008年2月沒有訂單活動的客戶和僱員。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"期望結果:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/91/91cb257735bd5caad4d7ae7ee5d364d3.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"方案一:EXCEPT","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)先用查詢1查詢出2008年1月份有訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)用查詢2查詢2008年2月份客戶的訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)用差集運算符查詢2008年1月有訂單活動而2008年2月沒有訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\nEXCEPT\nSELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20080201'\n AND orderdate < '20080301'\n``` sql\n\n**方案二:NOT EXISTS**\n\n必須保證custid,empid不能爲null,才能用NOT EXISTS進行查詢,如果custid或empid其中有null值存在,則不能用NOT EXISTS進行查詢,因爲比較NULL值的結果是UNKNOWN,這樣的行用NOT EXISTS查詢返回的子查詢的行會被過濾掉,所以最後的外查詢會多出NULL值的行,最後查詢結果中會多出NULL值的行。\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"SELECT custid ,empidFROM Sales.Orders AS O1WHERE orderdate >= '20080101'AND orderdate < '20080201'AND NOT EXISTS ( SELECT *FROM Sales.OrdersWHERE orderdate >= '20080201'AND orderdate < '20080301'AND custid = o1.custidAND empid = o1.empid )ORDER BY O1.custid ,","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":" O1.empid\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"\n如果我往Sales.Orders表中插入兩行數據:\n\n插入cutid=NULL,empid=1,orderdate='20080101'\n``` sql\nINSERT INTO [TSQLFundamentals2008].[Sales].[Orders]\n ( [custid] ,\n [empid] ,\n [orderdate] ,\n [requireddate] ,\n [shippeddate] ,\n [shipperid] ,\n [freight] ,\n [shipname] ,\n [shipaddress] ,\n [shipcity] ,\n [shipregion] ,\n [shippostalcode] ,\n [shipcountry]\n )\nVALUES ( NULL ,\n 1 ,\n '20080101' ,\n '20080101' ,\n '20080101' ,\n 1 ,\n 1 ,\n 'A' ,\n '20080101' ,\n 'A' ,\n 'A' ,\n 'A' ,\n 'A'\n )\nGO\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"插入cutid=NULL,empid=1,orderdate='20080201'","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"INSERT INTO [TSQLFundamentals2008].[Sales].[Orders]\n ( [custid] ,\n [empid] ,\n [orderdate] ,\n [requireddate] ,\n [shippeddate] ,\n [shipperid] ,\n [freight] ,\n [shipname] ,\n [shipaddress] ,\n [shipcity] ,\n [shipregion] ,\n [shippostalcode] ,\n [shipcountry]\n )\nVALUES ( NULL ,\n 1 ,\n '20080201' ,\n '20080101' ,\n '20080101' ,\n 1 ,\n 1 ,\n 'A' ,\n '20080101' ,\n 'A' ,\n 'A' ,\n 'A' ,\n 'A'\n )\nGO\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用方案一查詢出來結果爲50行,會把cutid=NULL,empid=1的行過濾掉","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用方案二查詢出來結果爲51行,不會把cutid=NULL,empid=1的行過濾掉","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用下面的方案可以解決上面的問題,需要處理cutid=NULL,或者empid=null的情況。返回50行","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders AS O1\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\n AND NOT EXISTS ( SELECT *\n FROM Sales.Orders\n WHERE orderdate >= '20080201'\n AND orderdate < '20080301'\n AND ( custid = o1.custid\n AND empid = o1.empid\n )\n OR ( o1.custid IS NULL\n AND custid IS NULL\n AND empid = o1.empid\n )\n OR ( o1.custid IS NULL\n AND custid IS NULL\n AND o1.empid IS NULL\n AND custid IS NULL\n )\n OR ( custid = o1.custid\n AND o1.empid IS NULL\n AND custid IS NULL\n ) )\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2.寫一個查詢,返回在2008年1月和在2008年2月都有訂單活動的客戶和僱員。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"期望結果:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9a/9a625d5180d419149800d97adfe234bc.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"方案一:INTERSECT","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(1)先用查詢1查詢出2008年1月份有訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(2)用查詢2查詢2008年2月份客戶的訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"(3)用交集運算符查詢2008年1月和2008年2月都有訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\nINTERSECT\nSELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20080201'\n AND orderdate < '20080301'\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"方案二:EXISTS","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"必須保證custid,empid不能爲null,才能用EXISTS進行查詢,如果custid或empid其中有null值存在,則不能用EXISTS進行查詢,因爲比較NULL值的結果是UNKNOWN,這樣的行用EXISTS查詢返回的子查詢的行會被過濾掉,所以最後的外查詢會少NULL值的行,最後查詢結果中會少NULL值的行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders AS O1\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\n AND EXISTS ( SELECT *\n FROM Sales.Orders\n WHERE orderdate >= '20080201'\n AND orderdate < '20080301'\n AND custid = o1.custid\n AND empid = o1.empid )\nORDER BY O1.custid ,\n O1.empid\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果我往Sales.Orders表中插入兩行數據:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"插入cutid=NULL,empid=1,orderdate='20080101'","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"插入cutid=NULL,empid=1,orderdate='20080201'","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用方案一查詢出來結果爲6行,不會把cutid=NULL,empid=1的行過濾掉","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用方案二查詢出來結果爲5行,會把cutid=NULL,empid=1的行過濾掉","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用下面的方案可以解決上面的問題,需要處理cutid=NULL,或者empid=null的情況。返回6行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders AS O1\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\n AND EXISTS ( SELECT *\n FROM Sales.Orders\n WHERE orderdate >= '20080201'\n AND orderdate < '20080301'\n AND ( custid = o1.custid\n AND empid = o1.empid\n )\n OR ( o1.custid IS NULL\n AND custid IS NULL\n AND empid = o1.empid\n )\n OR ( o1.custid IS NULL\n AND custid IS NULL\n AND o1.empid IS NULL\n AND custid IS NULL\n )\n OR ( custid = o1.custid\n AND o1.empid IS NULL\n AND custid IS NULL\n ) )\n","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3.寫一個查詢,返回在2008年1月和在2008年2月都有訂單活動,而在2007年沒有訂單活動的客戶和僱員","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"期望結果:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/49/492a9b9c17156bd8a66a49c8920beec1.jpeg","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"方案一:INTERSECT + EXCEPT","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\nINTERSECT\nSELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20080201'\n AND orderdate < '20080301'\nEXCEPT\nSELECT custid ,\n empid\nFROM Sales.Orders\nWHERE orderdate >= '20070101'\n AND orderdate < '20080101'\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"方案二:EXISTS + NOT EXISTS","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"sql"},"content":[{"type":"text","text":"SELECT custid ,\n empid\nFROM Sales.Orders AS O1\nWHERE orderdate >= '20080101'\n AND orderdate < '20080201'\n AND EXISTS ( SELECT *\n FROM Sales.Orders\n WHERE orderdate >= '20080201'\n AND orderdate < '20080301'\n AND ( custid = o1.custid\n AND empid = o1.empid\n )\n OR ( custid = o1.custid\n AND custid IS NULL\n AND empid = o1.empid\n )\n OR ( custid = o1.custid\n AND custid IS NULL\n AND empid = o1.empid\n AND custid IS NULL\n )\n OR ( custid = o1.custid\n AND empid = o1.empid\n AND custid IS NULL\n )\n OR ( custid = o1.custid\n AND custid IS NULL\n AND empid = o1.empid\n AND custid IS NULL\n ) )\n AND NOT EXISTS ( SELECT *\n FROM Sales.Orders\n WHERE orderdate >= '20070101'\n AND orderdate < '20080101'\n AND ( custid = o1.custid\n AND empid = o1.empid\n )\n AND ( custid = o1.custid\n AND empid = o1.empid\n )\n OR ( custid = o1.custid\n AND custid IS NULL\n AND empid = o1.empid\n )\n OR ( custid = o1.custid\n AND custid IS NULL\n AND empid = o1.empid\n AND custid IS NULL\n )\n OR ( custid = o1.custid\n AND empid = o1.empid\n AND custid IS NULL\n )\n OR ( custid = o1.custid\n AND custid IS NULL\n AND empid = o1.empid\n AND custid IS NULL\n ) )\nORDER BY O1.custid ,\n O1.empid\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"參考資料:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"《SQL2008技術內幕:T-SQL語言基礎》","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"歡迎關注我的公衆號:「","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"悟空聊架構","attrs":{}}],"attrs":{}},{"type":"text","text":"」","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作者簡介:8 年互聯網職場老兵|全棧工程師|90 後超級奶爸|開源踐行者|公衆號萬粉原創號主。藍橋簽約作者,著有《JVM 性能調優實戰》專欄,手寫了一套 7 萬字 SpringCloud 實戰總結和 3 萬字分佈式算法總結。歡迎關注我的公衆號「悟空聊架構」,免費獲取資料學習。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"我是悟空,努力變強,變身超級賽亞人!","attrs":{}}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章