SQL 必知必會(huì)(第3版)

出版時(shí)間:2007-07-01  出版社:人民郵電出版社  作者:(英)Ben Forta  頁(yè)數(shù):204  譯者:鐘鳴,劉曉霞  
Tag標(biāo)簽:無(wú)  

內(nèi)容概要

  SQL 是目前使用最為廣泛的數(shù)據(jù)庫(kù)語(yǔ)言之一。本書沒有涉及理論,而是從實(shí)踐出發(fā),由淺入深地講解了廣大讀者所必需的SQL 知識(shí),適用于各種主流數(shù)據(jù)庫(kù)。實(shí)例豐富,便于查閱。本書涉及不同平臺(tái)上數(shù)據(jù)的排序、過濾和分組,以及表、視圖、聯(lián)結(jié)、子查詢、游標(biāo)、存儲(chǔ)過程和觸發(fā)器等內(nèi)容,通過本書讀者可以系統(tǒng)地學(xué)習(xí)到SQL 的知識(shí)和方法?! ”緯⒅貙?shí)用性,操作性很強(qiáng),適合于SQL 的初學(xué)者學(xué)習(xí)和廣大軟件開發(fā)及管理人員參考。

作者簡(jiǎn)介

  Ben Forta是世界知名的技術(shù)作家,也是Adobe技術(shù)界最為知名的專家之一,目前擔(dān)任Adobe公司的高級(jí)技術(shù)推廣專家。他具有計(jì)算機(jī)行業(yè)20多年工作經(jīng)驗(yàn),多年來(lái)撰寫了十幾本技術(shù)圖書,其中不少是世界暢銷書,已被翻譯為十幾種文字。除本書外,他撰寫的《正則表達(dá)式必知必會(huì)》也即將由人民郵電出版社出版。

書籍目錄

第1章 了解SQL第2章 檢索數(shù)據(jù)第3章 排序檢索數(shù)據(jù)第4章 過濾數(shù)據(jù)第5章 高級(jí)數(shù)據(jù)過濾第6章 用通配符進(jìn)行過濾第7章 創(chuàng)建計(jì)算字段第8章 使用數(shù)據(jù)處理函數(shù)第9章 匯總數(shù)據(jù)第10章 分組數(shù)據(jù)第11章 使用子查詢第12章 聯(lián)結(jié)表第13章 創(chuàng)建高級(jí)聯(lián)結(jié)第14章 組合查詢第15章 插入數(shù)據(jù)第16章 更新和刪除數(shù)據(jù)第17章 創(chuàng)建和操縱表第18章 使用視圖第19章 使用存儲(chǔ)過程第20章 管理事務(wù)處理第21章 使用游標(biāo)第22章 了解高級(jí)SQL特性附錄A 樣例表腳本A.1 樣例表A.2 獲得樣例表A.2.1 下載可供使用的Microsoft Access MDB文件A.2.2 下載DBMS SQL腳本附錄B 流行的應(yīng)用系統(tǒng)B.1 使用Aqua Data StudioB.2 使用DB2B.3 使用Macromedia ColdFusionB.4 使用Microsoft AccessB.5 使用Microsoft ASPB.6 使用Microsoft ASP.NETB.7 使用Microsoft QueryB.8 使用Microsoft SQL ServerB.9 使用MySQLB.10 使用OracleB.11 使用PHPB.12 使用PostgreSQLB.13 使用Query ToolB.14 使用SybaseB.15 配置ODBC數(shù)據(jù)源附錄C SQL語(yǔ)句的語(yǔ)法C.1 ALTER TABLEC.2 COMMITC.3 CREATE INDEXC.4 CREATE PROCEDUREC.5 CREATE TABLEC.6 CREATE VIEWC.7 DELETEC.8 DROPC.9 INSERTC.10 INSERT SELECTC.11 ROLLBACKC.12 SELECTC.13 UPDATE附錄D SQL數(shù)據(jù)類型D.1 串?dāng)?shù)據(jù)類型D.2 數(shù)值數(shù)據(jù)類型D.3 日期和時(shí)間數(shù)據(jù)類型D.4 二進(jìn)制數(shù)據(jù)類型附錄E SQL保留字索引

編輯推薦

  《SQL必知必會(huì)》(第3版)注重實(shí)用性,操作性很強(qiáng),適合于SQL的初學(xué)者學(xué)習(xí)和廣大軟件開發(fā)及管理人員參考。

圖書封面

圖書標(biāo)簽Tags

無(wú)

評(píng)論、評(píng)分、閱讀與下載


    SQL 必知必會(huì)(第3版) PDF格式下載


用戶評(píng)論 (總計(jì)17條)

 
 

  •     對(duì)于行家來(lái)說(shuō),這應(yīng)該是本非常非常基礎(chǔ)的書,但是這本書的目的也就是讓菜鳥能夠入門。知道那些數(shù)據(jù)庫(kù)的常用操作以及概念...通讀全書基本不累,理論上周末兩天就可以解決...話說(shuō)本人不才,畢業(yè)N年從未學(xué)習(xí)過數(shù)據(jù)庫(kù),現(xiàn)在算是了解了數(shù)據(jù)庫(kù)的基本操作語(yǔ)法,以及相關(guān)術(shù)語(yǔ)的出處,接下來(lái)對(duì)于那些數(shù)據(jù)庫(kù)操作的玩意兒應(yīng)該有底了
      最后,說(shuō)句受益匪淺
  •     失望。
      下個(gè)月項(xiàng)目要用到數(shù)據(jù)庫(kù),翻了翻這本書。
      只能說(shuō)是sql基本命令,各種select用法,對(duì)數(shù)據(jù)庫(kù)的原理和設(shè)計(jì)沒有任何介紹。屬于2天看完,1周忘掉的節(jié)奏。如果用到數(shù)據(jù)庫(kù)忘記sql語(yǔ)法,建議看看http://www.w3school.com.cn/算了,或者直接google。
      個(gè)人感覺,這本書用途不大。
  •     總體來(lái)說(shuō)這是一本非?;A(chǔ)的數(shù)據(jù)庫(kù)方面的書。這本書幾乎涉及了SQL的全部?jī)?nèi)容。涉及的都不深入,比如存儲(chǔ)過程、事務(wù)處理、約束、游標(biāo)這些高級(jí)內(nèi)容就只是一筆帶過,作為一本初級(jí)入門書能夠大致了解一下高級(jí)主題為進(jìn)一步深入了解做準(zhǔn)備。
      在基礎(chǔ)語(yǔ)法方面做得很優(yōu)秀。SELECT查詢語(yǔ)句由淺入深講得很容易理解。由最簡(jiǎn)單的檢索單個(gè)列,檢索多列,排序,WHERE子句過濾行到計(jì)算字段,使用函數(shù)以及匯總查詢和聯(lián)結(jié)多表查詢。這些方面講得透徹。
      比如,匯總查詢時(shí),會(huì)提醒WHERE子句應(yīng)位于GROUP BY子句之前,并且出現(xiàn)在SELECT后面的列名,要么是匯總字段,要么是GROUP BY子句的列名。
      不足之處是在插入和刪除講得簡(jiǎn)略,似乎作者認(rèn)為只要講好了查詢,這本書的工作就算是完成了。對(duì)于高級(jí)主題更是涉及很少。
      在使用這本書的時(shí)候有幾點(diǎn)需要注意:
      1、參考每個(gè)DBMS的聯(lián)機(jī)文檔,因?yàn)槊總€(gè)DBMS使用的SQL語(yǔ)法都不一致,在SQLServer 2008上能運(yùn)行的SQL在MySQL上就不一定能運(yùn)行。作者提的SQL也不是所有都能在每一個(gè)DBMS上運(yùn)行。比如在ACCESS上是不支持CREATE VIEW操作的(解決的辦法是直接SELECT查詢保存查詢,并在另外一個(gè)查詢中引用此查詢名)。同時(shí)ACCESS不支持在定義數(shù)據(jù)表時(shí)使用Decimal數(shù)據(jù)類型。
      2、一定要對(duì)每一個(gè)SQL試驗(yàn)一遍,甚至應(yīng)該想出更多需要去查詢的信息。盡可能多地讓自己去想解決的方法和給自己出難題。如果覺得沒有,可以到論壇上CSDN上找別入無(wú)法解決的問題。
      ——————————————————————————————-————
      總體上,這本書是一本比較好的入門書。對(duì)于盡了解SQL是很有幫助的。
  •     很棒的書。
      老外的書總是那么有條理,由深入淺。你越看越想看。雖然后面的速度會(huì)慢些,內(nèi)容難度有所提高。但是看下來(lái)后你會(huì)有對(duì)SQL的增刪改查足矣。
      這是一本基礎(chǔ)的書 ,不是sql基礎(chǔ)理論,而是一些常見應(yīng)用的知識(shí)講解。
      值得一讀。
      講的“淺”,但是知識(shí)很實(shí)用 很基本的知識(shí),也是使用中需要掌握的。由于現(xiàn)在的數(shù)據(jù)庫(kù)都有自己的方言,所以結(jié)合數(shù)據(jù)管理器的使用方法是另一說(shuō)。你需要看其他的書來(lái)了解。但是基礎(chǔ)知識(shí)是通用的。
  •     記得是從候清榮那里借閱的,通過這本書可以輕松全面地掌握最常用的SQL,配套了示例腳本可以練習(xí)。通過本書可以快速入門。對(duì)我第一次找工作起了很大的作用。到甲方做項(xiàng)目經(jīng)理三年了,別說(shuō)程序,現(xiàn)在sql都寫得很少了,準(zhǔn)備再郵購(gòu)一本,抽空溫習(xí)一下。
  •     
        注1:該筆記為未完成版(最后修改日期為2009.3.25)
        注2:轉(zhuǎn)帖請(qǐng)注明出處(筆記作者:城市行走者)
      
      第0章 安裝mysql以及建庫(kù)、建表、導(dǎo)入數(shù)據(jù)
      第1章 了解SQL
      1.1數(shù)據(jù)庫(kù)基礎(chǔ)
      1.2 什么是SQL
      1.3 動(dòng)手實(shí)踐
      第2章 檢索數(shù)據(jù)
      2.1 SELECT 語(yǔ)句
      2.2 檢索單個(gè)列
      2.3 檢索多個(gè)列
      2.4 檢索所有列
      第3章 排序檢索數(shù)據(jù)
      3.1 排序數(shù)據(jù)
      3.2 按多個(gè)列排序
      3.3 按列位置排序
      3.4 指定排序方向
      第4章 過濾數(shù)據(jù)
      4.1 使用WHERE子句
      4.2 WHERE子句操作符
      4.2.1 檢查單個(gè)值
      4.2.2 不匹配檢查
      4.2.3 范圍值檢查
      4.2.4 空值檢查
      第 5 章 高級(jí)數(shù)據(jù)過濾
      5.1 組合WHERE子句
      5.1.1 AND操作符 (與運(yùn)算)
      5.1.2 OR操作符 (或運(yùn)算)
      5.1.3 計(jì)算次序(操作符的優(yōu)先級(jí))
      5.2 IN操作符
      5.3 NOT操作符
      第6章 用通配符進(jìn)行過濾
      6.1 LIKE操作符
      6.1.1 百分號(hào)(%)通配符
      6.1.2 下劃線(_)通配符
      6.1.3 方括號(hào)([])通配符
      6.2 使用通配符的技巧
      附錄:MySQL正則表達(dá)式
      第7章 創(chuàng)建計(jì)算字段
      7.1 計(jì)算字段
      7.2 拼接字段
      7.3 執(zhí)行算術(shù)計(jì)算
      第8章 使用數(shù)據(jù)處理函數(shù)
      8.1 函數(shù)
      8.2 使用函數(shù)
      8.2.1 文本處理函數(shù)
      8.2.2 日期和時(shí)間處理函數(shù)
      8.2.3 數(shù)值處理函數(shù)
      第9章 匯總數(shù)據(jù)
      9.1 聚集函數(shù)
      9.2 聚集不同值
      9.3 組合聚集函數(shù)
      第10章 分組數(shù)據(jù)
      10.1 數(shù)據(jù)分組
      10.2 創(chuàng)建分組
      10.3 過濾分組
      10.4 分組和排序
      10.5 SELECT子句順序
      第11章 使用子查詢
      11.1 子查詢
      11.2 利用子查詢進(jìn)行過濾
      11.3 作為計(jì)算字段使用子查詢
      第12章 聯(lián)結(jié)表(join table)
      12.1 聯(lián)結(jié)
      12.1.1 關(guān)系表
      12.2 創(chuàng)建聯(lián)結(jié)
      12.2.2 內(nèi)部聯(lián)結(jié)
      12.2.3 聯(lián)結(jié)多個(gè)表
      第13章 創(chuàng)建高級(jí)聯(lián)結(jié)
      13.1 使用表別名
      13.2 使用不同類型的聯(lián)結(jié)
      13.2.1 自聯(lián)結(jié)
      13.2.2 自然聯(lián)結(jié)
      13.2.3 外部聯(lián)結(jié)
      13.3 使用帶聚集函數(shù)的聯(lián)結(jié)
      13.4 使用聯(lián)結(jié)和聯(lián)結(jié)條件
      第14章 組合查詢
      14.1 組合查詢
      14.2 創(chuàng)建組合查詢
      14.2.1 使用UNION
      14.2.2 UNION規(guī)則
      14.2.3 包含或取消重復(fù)的行
      14.2.4 對(duì)組合查詢排序
      第15章 插入數(shù)據(jù)
      15.1 插入數(shù)據(jù)
      15.1.1 插入完整的行
      15.1.2 插入部分行
      15.1.3 插入檢索出的數(shù)據(jù)
      15.2 從一個(gè)表復(fù)制到另一個(gè)表
      第16章 更新和刪除數(shù)據(jù)
      16.1 更新數(shù)據(jù)
      16.2 刪除數(shù)據(jù)
      16.3 更新和刪除的指導(dǎo)原則
      第17章 創(chuàng)建和操縱表
      17.1 創(chuàng)建表
      17.1.1 表創(chuàng)建基礎(chǔ)
      17.1.2 使用NULL值
      17.1.3 制定默認(rèn)值
      17.2 更新表結(jié)構(gòu)
      17.3 刪除表
      17.4 重命名表名
      第18章 使用視圖
      18.1 視圖
      18.1.1 為什使用視圖
      18.1.2 視圖的規(guī)則和限制
      18.2 創(chuàng)建視圖
      18.2.1 利用視圖簡(jiǎn)化復(fù)雜的聯(lián)結(jié)
      18.2.2 用視圖重新格式化檢索出的數(shù)據(jù)
      18.2.3 用視圖過濾不想要的數(shù)據(jù)
      18.2.4 使用視圖與計(jì)算字段
      18.3 小結(jié)
      第19章 使用存儲(chǔ)過程
      附錄: Oracle 和 mysql 的一些簡(jiǎn)單SQL操作命令對(duì)比
      
      第0章 安裝mysql以及建庫(kù)、建表、導(dǎo)入數(shù)據(jù)
      安裝mysql時(shí),向?qū)Ы⒌墓芾韱T用戶和密碼
      root:lvhejia001;'
      
       一、連接mysql。
      
       1、首先在打開DOS窗口,再鍵入命令mysql -uroot -p, 回車后提示你輸密碼。
      2、直接利用開始菜單!開始----程序---mysql5.0
      
      二、建庫(kù)、建表、導(dǎo)入數(shù)據(jù)
      1、 顯示數(shù)據(jù)庫(kù)列表。
      例子:
      mysql> show tables;
      +-------------------+
      | Tables_in_example |
      +-------------------+
      | customers |
      | orderitems |
      | orders |
      | products |
      | vendors |
      +-------------------+
      5 rows in set (0.00 sec)
      剛開始時(shí)才兩個(gè)數(shù)據(jù)庫(kù):mysql和test。 mysql庫(kù)很重要它里面有mysql的系統(tǒng)信息,
      我們改密碼和新增用戶,實(shí)際上就是用這個(gè)庫(kù)進(jìn)行操作。
      
      2、 顯示庫(kù)中的數(shù)據(jù)表:
      語(yǔ)法:use 數(shù)據(jù)庫(kù)名; //打開庫(kù),學(xué)過FOXBASE的一定不會(huì)陌生吧
       show 表名;
      
      3、 顯示數(shù)據(jù)表的結(jié)構(gòu):
      語(yǔ)法:describe 表名;
      
      4、 建庫(kù):
      語(yǔ)法:create database 庫(kù)名;
      
      例子:
      mysql> create database example;
      Query OK, 1 row affected (0.00 sec)
      
      mysql> use example;
      Database changed
      
      mysql> show tables;
      Empty set (0.00 sec)
      
      
      
      5、 建表:
      語(yǔ)法:use 庫(kù)名;
       create table 表名(字段設(shè)定列表);
      
      使用Ben Forta提供的例子,直接復(fù)制粘貼。
      -------------------------
      -- Create Customers table
      -------------------------
      CREATE TABLE Customers
      (
       cust_id char(10) NOT NULL ,
       cust_name char(50) NOT NULL ,
       cust_address char(50) NULL ,
       cust_city char(50) NULL ,
       cust_state char(5) NULL ,
       cust_zip char(10) NULL ,
       cust_country char(50) NULL ,
       cust_contact char(50) NULL ,
       cust_email char(255) NULL
      );
      ……
      無(wú)錯(cuò)誤提示,再檢查一下
      mysql> show tables;
      +-------------------+
      | Tables_in_example |
      +-------------------+
      | customers |
      | orderitems |
      | orders |
      | products |
      | vendors |
      +-------------------+
      5 rows in set (0.00 sec)
      
      6、導(dǎo)入數(shù)據(jù)
      還是使用Ben Forta提供的例子,直接復(fù)制粘貼。
      ---------------------------
      -- Populate Customers table
      ---------------------------
      INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
      VALUES('1000000001', 'Village Toys', '200 Maple Lane', 'Detroit', 'MI', '44444', 'USA', 'John Smith', 'sales@villagetoys.com');
      …… ……
      
      無(wú)錯(cuò)誤提示
      第1章 了解SQL
      1.1數(shù)據(jù)庫(kù)基礎(chǔ)
      1.1.1 數(shù)據(jù)庫(kù)(database):保存有組織的數(shù)據(jù)的倉(cāng)庫(kù)(數(shù)據(jù)集合)。
      1.1.2 表(table):一種結(jié)構(gòu)化的文件。
      1.1.3 列(column):表中的一個(gè)字段(field)。
      數(shù)據(jù)類型(data type):每列都有相應(yīng)的數(shù)據(jù)類型,它限制或容許該列中存儲(chǔ)的數(shù)據(jù)。
      注意:雖然大多數(shù)的數(shù)據(jù)類型得到一致的支持,但許多更為高級(jí)的數(shù)據(jù)類型卻不是這樣。更糟的是,我們偶熱會(huì)發(fā)現(xiàn)相同的數(shù)據(jù)類型在不同的DBMS中具有不同的名稱。對(duì)此用戶毫無(wú)辦法,重要的是在創(chuàng)建表結(jié)構(gòu)時(shí)要記住這些差異。
      1.1.4 行(row):表中的一個(gè)記錄(record)。
      1.1.5 主鍵(primary key):一列(或一組列),其值能夠唯一標(biāo)識(shí)表中的每一列。
      作為主鍵的列,需要滿足以下條件:
      1、任意兩行都不具有相同的主鍵值;
      2、每一行都必須具有一個(gè)主鍵值(主鍵列不允許NULL值);
      3、主鍵列中的值不允許修改或更新;
      4、主鍵值不能重用(如果某行從表中刪除,它的主鍵不能賦給以后的新行)
      
      1.2 什么是SQL
      SQL(Structured Query Language):結(jié)構(gòu)化查詢語(yǔ)言,是一種專門用來(lái)與數(shù)據(jù)庫(kù)通信的語(yǔ)言。
      注意:標(biāo)準(zhǔn)SQL有ANSI標(biāo)準(zhǔn)委員會(huì)管理,從而成為ANSI SQL。各個(gè)DBMS供應(yīng)商通過增加語(yǔ)句或指令,對(duì)標(biāo)準(zhǔn)SQL進(jìn)行擴(kuò)展。
      
      1.3 動(dòng)手實(shí)踐
      這里使用的DBMS為MySQL。
      第2章 檢索數(shù)據(jù)
      2.1 SELECT 語(yǔ)句
      關(guān)鍵字(keyword):作為SQL組成部分的保留字。
      附錄E ——SQL保留字(略)
      
      2.2 檢索單個(gè)列
      mysql> select prod_name
       -> from products;
      
      +---------------------+
      | prod_name |
      +---------------------+
      | Fish bean bag toy |
      | Bird bean bag toy |
      | Rabbit bean bag toy |
      | 8 inch teddy bear |
      | 12 inch teddy bear |
      | 18 inch teddy bear |
      | Raggedy Ann |
      | King doll |
      | Queen doll |
      +---------------------+
      9 rows in set (0.20 sec)
      
      注意:1、SQL語(yǔ)句可以分行。
       2、多條SQL語(yǔ)句必須以分號(hào)(;)分隔。
       3、SQL語(yǔ)句不區(qū)分大小寫。
      
      2.3 檢索多個(gè)列
      列名之間必須以逗號(hào)分隔。
      mysql> select prod_id, prod_name, prod_price
       -> from products;
      
      +---------+---------------------+------------+
      | prod_id | prod_name | prod_price |
      +---------+---------------------+------------+
      | BNBG01 | Fish bean bag toy | 3.49 |
      | BNBG02 | Bird bean bag toy | 3.49 |
      | BNBG03 | Rabbit bean bag toy | 3.49 |
      | BR01 | 8 inch teddy bear | 5.99 |
      | BR02 | 12 inch teddy bear | 8.99 |
      | BR03 | 18 inch teddy bear | 11.99 |
      | RGAN01 | Raggedy Ann | 4.99 |
      | RYL01 | King doll | 9.49 |
      | RYL02 | Queen doll | 9.49 |
      +---------+---------------------+------------+
      9 rows in set (0.00 sec)
      
      2.4 檢索所有列
      通配符——星號(hào)(*)
      mysql> select *
       -> from products;
      第3章 排序檢索數(shù)據(jù)
      3.1 排序數(shù)據(jù)
      mysql> select prod_name
       -> from products
       -> order by prod_name;
      +---------------------+
      | prod_name |
      +---------------------+
      | 12 inch teddy bear |
      | 18 inch teddy bear |
      | 8 inch teddy bear |
      | Bird bean bag toy |
      | Fish bean bag toy |
      | King doll |
      | Queen doll |
      | Rabbit bean bag toy |
      | Raggedy Ann |
      +---------------------+
      9 rows in set (0.16 sec)
      
      注意:order by子句必須是select語(yǔ)句中的最后一條子句。
      
      3.2 按多個(gè)列排序
      
      mysql> select prod_id, prod_price, prod_name
       -> from products
       -> order by prod_price, prod_name;
      
      +---------+------------+---------------------+
      | prod_id | prod_price | prod_name |
      +---------+------------+---------------------+
      | BNBG02 | 3.49 | Bird bean bag toy |
      | BNBG01 | 3.49 | Fish bean bag toy |
      | BNBG03 | 3.49 | Rabbit bean bag toy |
      | RGAN01 | 4.99 | Raggedy Ann |
      | BR01 | 5.99 | 8 inch teddy bear |
      | BR02 | 8.99 | 12 inch teddy bear |
      | RYL01 | 9.49 | King doll |
      | RYL02 | 9.49 | Queen doll |
      | BR03 | 11.99 | 18 inch teddy bear |
      +---------+------------+---------------------+
      9 rows in set (0.00 sec)
      
      3.3 按列位置排序
      mysql> select prod_id, prod_price, prod_name
       -> from products
       -> order by 2, 3;
      
      +---------+------------+---------------------+
      | prod_id | prod_price | prod_name |
      +---------+------------+---------------------+
      | BNBG02 | 3.49 | Bird bean bag toy |
      | BNBG01 | 3.49 | Fish bean bag toy |
      | BNBG03 | 3.49 | Rabbit bean bag toy |
      | RGAN01 | 4.99 | Raggedy Ann |
      | BR01 | 5.99 | 8 inch teddy bear |
      | BR02 | 8.99 | 12 inch teddy bear |
      | RYL01 | 9.49 | King doll |
      | RYL02 | 9.49 | Queen doll |
      | BR03 | 11.99 | 18 inch teddy bear |
      +---------+------------+---------------------+
      9 rows in set (0.00 sec)
      
      3.4 指定排序方向
      排序時(shí)默認(rèn)為升序ASC(ASDENDING),如果需要降序,則通過關(guān)鍵字DESC(DESCENDING)。
      mysql> select prod_id, prod_price, prod_name
       -> from products
       -> order by prod_price desc;
      
      +---------+------------+---------------------+
      | prod_id | prod_price | prod_name |
      +---------+------------+---------------------+
      | BR03 | 11.99 | 18 inch teddy bear |
      | RYL01 | 9.49 | King doll |
      | RYL02 | 9.49 | Queen doll |
      | BR02 | 8.99 | 12 inch teddy bear |
      | BR01 | 5.99 | 8 inch teddy bear |
      | RGAN01 | 4.99 | Raggedy Ann |
      | BNBG01 | 3.49 | Fish bean bag toy |
      | BNBG02 | 3.49 | Bird bean bag toy |
      | BNBG03 | 3.49 | Rabbit bean bag toy |
      +---------+------------+---------------------+
      9 rows in set (0.00 sec)
      
      注意:DESC關(guān)鍵字之應(yīng)用到直接位于其前面的列名。如果想對(duì)多個(gè)列進(jìn)行排序,必須對(duì)每個(gè)列指定DESC關(guān)鍵字。
      第4章 過濾數(shù)據(jù)
      4.1 使用WHERE子句
      mysql> select prod_name, prod_price
       -> from products
       -> where prod_price = 3.49;
      
      +---------------------+------------+
      | prod_name | prod_price |
      +---------------------+------------+
      | Fish bean bag toy | 3.49 |
      | Bird bean bag toy | 3.49 |
      | Rabbit bean bag toy | 3.49 |
      +---------------------+------------+
      3 rows in set (0.00 sec)
      
      4.2 WHERE子句操作符
      
      操作符 說(shuō)明
      =
      !=
      <>
      <
      <=
      >
      >=
      BETWEEN
      IS UNLL
      
      4.2.1 檢查單個(gè)值
      mysql> select prod_name, prod_price
       -> from products
       -> where prod_price < 10;
      
      +---------------------+------------+
      | prod_name | prod_price |
      +---------------------+------------+
      | Fish bean bag toy | 3.49 |
      | Bird bean bag toy | 3.49 |
      | Rabbit bean bag toy | 3.49 |
      | 8 inch teddy bear | 5.99 |
      | 12 inch teddy bear | 8.99 |
      | Raggedy Ann | 4.99 |
      | King doll | 9.49 |
      | Queen doll | 9.49 |
      +---------------------+------------+
      8 rows in set (0.00 sec)
      4.2.2 不匹配檢查
      mysql> select vend_id, prod_name
       -> from products
       -> where vend_id != 'DLL01';
      +---------+--------------------+
      | vend_id | prod_name |
      +---------+--------------------+
      | BRS01 | 8 inch teddy bear |
      | BRS01 | 12 inch teddy bear |
      | BRS01 | 18 inch teddy bear |
      | FNG01 | King doll |
      | FNG01 | Queen doll |
      +---------+--------------------+
      5 rows in set (0.00 sec)
      
      注意:!=和<>通常可以互換。但是,并非所有的DBMS都支持這兩種操作符。例如Microsoft Access支持<>而不支持!=。如有疑問,請(qǐng)參閱相應(yīng)的DBMS文檔。
      4.2.3 范圍值檢查
      mysql> select prod_name, prod_price
       -> from products
       -> where prod_price between 5 and 10;
      
      +--------------------+------------+
      | prod_name | prod_price |
      +--------------------+------------+
      | 8 inch teddy bear | 5.99 |
      | 12 inch teddy bear | 8.99 |
      | King doll | 9.49 |
      | Queen doll | 9.49 |
      +--------------------+------------+
      4 rows in set (0.00 sec)
      4.2.4 空值檢查
      mysql> select vend_name, vend_state
       -> from vendors
       -> where vend_state is null;
      
      +----------------+------------+
      | vend_name | vend_state |
      +----------------+------------+
      | Fun and Games | NULL |
      | Jouets et ours | NULL |
      +----------------+------------+
      2 rows in set (0.00 sec)
      第 5 章 高級(jí)數(shù)據(jù)過濾
      5.1 組合WHERE子句
      操作符(operateor):用來(lái)聯(lián)接或改變WHERE子句中的子句的關(guān)鍵詞。也稱邏輯操作符(logical operator)。
      5.1.1 AND操作符 (與運(yùn)算)
      mysql> select prod_id, prod_price, prod_name
       -> from products
       -> where vend_id = 'DLL01' and prod_price <= 4;
      
      +---------+------------+---------------------+
      | prod_id | prod_price | prod_name |
      +---------+------------+---------------------+
      | BNBG01 | 3.49 | Fish bean bag toy |
      | BNBG02 | 3.49 | Bird bean bag toy |
      | BNBG03 | 3.49 | Rabbit bean bag toy |
      +---------+------------+---------------------+
      3 rows in set (0.00 sec)
      5.1.2 OR操作符 (或運(yùn)算)
      mysql> select vend_id, prod_name, prod_price
       -> from products
       -> where vend_id = 'DLL01' or vend_id = 'BRS01';
      +---------+---------------------+------------+
      | vend_id | prod_name | prod_price |
      +---------+---------------------+------------+
      | DLL01 | Fish bean bag toy | 3.49 |
      | DLL01 | Bird bean bag toy | 3.49 |
      | DLL01 | Rabbit bean bag toy | 3.49 |
      | BRS01 | 8 inch teddy bear | 5.99 |
      | BRS01 | 12 inch teddy bear | 8.99 |
      | BRS01 | 18 inch teddy bear | 11.99 |
      | DLL01 | Raggedy Ann | 4.99 |
      +---------+---------------------+------------+
      
      注意:事實(shí)上,許多DBMS在OR子句的第一個(gè)條件滿足的情況下,不再計(jì)算第二個(gè)條件(即,第一個(gè)條件滿足時(shí),不管第二個(gè)條件是否滿足,相應(yīng)的行都將被檢索出來(lái))。
      5.1.3 計(jì)算次序(操作符的優(yōu)先級(jí))
      以下列表顯示了操作符優(yōu)先級(jí)的由低到高的順序。排列在同一行的操作符具有相同的優(yōu)先級(jí)。
      
      :=
      ||, OR, XOR
      &&, AND
      NOT
      BETWEEN, CASE, WHEN, THEN, ELSE
      =, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
      |
      &
      <<, >>
      -, +
      *, /, DIV, %, MOD
      ^
      - (一元減號(hào)), ~ (一元比特反轉(zhuǎn))
      !
      BINARY, COLLATE
      
      注意:不要過分依賴默認(rèn)的優(yōu)先級(jí)。任何時(shí)候使用具有AND和OR的操作符的WHERE子句時(shí),都應(yīng)該使用圓括號(hào)明確的分組操作符。使用圓括號(hào)沒有什么壞處,它能消除歧義。
      5.2 IN操作符
      mysql> select vend_id, prod_name, prod_price
       -> from products
       -> where vend_id = 'DLL01' or vend_id = 'BRS01';
      
      +---------+---------------------+------------+
      | vend_id | prod_name | prod_price |
      +---------+---------------------+------------+
      | DLL01 | Fish bean bag toy | 3.49 |
      | DLL01 | Bird bean bag toy | 3.49 |
      | DLL01 | Rabbit bean bag toy | 3.49 |
      | BRS01 | 8 inch teddy bear | 5.99 |
      | BRS01 | 12 inch teddy bear | 8.99 |
      | BRS01 | 18 inch teddy bear | 11.99 |
      | DLL01 | Raggedy Ann | 4.99 |
      +---------+---------------------+------------+
      7 rows in set (0.00 sec)
      
      注意:IN操作符可以完成OR操作符完全相同的功能。
      
      IN操作符最大的優(yōu)點(diǎn)是可以包含其他SELECT語(yǔ)句,使得能夠更動(dòng)態(tài)的建立WHERE子句。詳細(xì)介紹在第11章。
      5.3 NOT操作符
      mysql> select vend_id, prod_name, prod_price
       -> from products
       -> where not vend_id = 'DLL01' ;
      
      +---------+--------------------+------------+
      | vend_id | prod_name | prod_price |
      +---------+--------------------+------------+
      | BRS01 | 8 inch teddy bear | 5.99 |
      | BRS01 | 12 inch teddy bear | 8.99 |
      | BRS01 | 18 inch teddy bear | 11.99 |
      | FNG01 | King doll | 9.49 |
      | FNG01 | Queen doll | 9.49 |
      +---------+--------------------+------------+
      5 rows in set (0.00 sec)
      
      注意:NOT操作符在復(fù)雜子句中用處更大,比如與IN操作符聯(lián)合使用——NOT IN。
      第6章 用通配符進(jìn)行過濾
      6.1 LIKE操作符
      通配符(wildcard):用來(lái)匹配值(文本字段,即“串”)的一部分的特殊字符。
      搜索模式(search pattern):由字面值、通配符或者兩者組合構(gòu)成的搜索條件。
      6.1.1 百分號(hào)(%)通配符
      百分號(hào)(%)表示任何字符出現(xiàn)任意次數(shù)。
      mysql> select prod_name
       -> from products
       -> where prod_name like 'fish%';
      
      +-------------------+
      | prod_name |
      +-------------------+
      | Fish bean bag toy |
      +-------------------+
      1 row in set (0.01 sec)
      
      注意:根據(jù)DBMS的不同及其配置,搜索可以是區(qū)分大小寫的!
      
      mysql> select prod_name
       -> from products
       -> where prod_name like 'f%y';
      
      +-------------------+
      | prod_name |
      +-------------------+
      | Fish bean bag toy |
      +-------------------+
      1 row in set (0.00 sec)
      注意:要特別小心后面所跟的空格。許多DBMS,包括Microsoft Access,都用空格來(lái)填補(bǔ)字段內(nèi)容。
      6.1.2 下劃線(_)通配符
      下劃線(_)表示任意單個(gè)字符。
      mysql> select prod_name
       -> from products
       -> where prod_name like '_ inch teddy bear';
      
      +-------------------+
      | prod_name |
      +-------------------+
      | 8 inch teddy bear |
      +-------------------+
      1 row in set (0.00 sec)
      
      mysql> select prod_name
       -> from products
       -> where prod_name like '% inch teddy bear';
      
      +--------------------+
      | prod_name |
      +--------------------+
      | 8 inch teddy bear |
      | 12 inch teddy bear |
      | 18 inch teddy bear |
      +--------------------+
      3 rows in set (0.00 sec)
      6.1.3 方括號(hào)([])通配符
      方括號(hào)([])通配符:用來(lái)指定一個(gè)字符集。
      注意:并不是所有的SBMS都支持方括號(hào)([])通配符
      6.2 使用通配符的技巧
      除非絕對(duì)有必要,否則不要把它們用在搜索模式的開始處。把通配符置于搜索模式的開始處,搜索起來(lái)是最慢的。
      
      
      附錄:MySQL正則表達(dá)式
      
      正則表達(dá)式是為復(fù)雜搜索指定模式的強(qiáng)大方式。
      MySQL采用Henry Spencer的正則表達(dá)式實(shí)施,其目標(biāo)是符合POSIX 1003.2。請(qǐng)參見附錄C:感謝。MySQL采用了擴(kuò)展的版本,以支持在SQL語(yǔ)句中與REGEXP操作符一起使用的模式匹配操作。請(qǐng)參見3.3.4.7節(jié),“模式匹配”。
      在本附錄中,歸納了在MySQL中可用于REGEXP操作的特殊字符和結(jié)構(gòu),并給出了一些示例。本附錄未包含可在Henry Spencer的regex(7)手冊(cè)頁(yè)面中發(fā)現(xiàn)的所有細(xì)節(jié)。該手冊(cè)頁(yè)面包含在MySQL源碼分發(fā)版中,位于regex目錄下的regex.7文件中。
      正則表達(dá)式描述了一組字符串。最簡(jiǎn)單的正則表達(dá)式是不含任何特殊字符的正則表達(dá)式。例如,正則表達(dá)式hello匹配hello。
      非平凡的正則表達(dá)式采用了特殊的特定結(jié)構(gòu),從而使得它們能夠與1個(gè)以上的字符串匹配。例如,正則表達(dá)式hello|word匹配字符串hello或字符串word。
      作為一個(gè)更為復(fù)雜的示例,正則表達(dá)式B[an]*s匹配下述字符串中的任何一個(gè):Bananas,Baaaaas,Bs,以及以B開始、以s結(jié)束、并在其中包含任意數(shù)目a或n字符的任何其他字符串。
      對(duì)于REGEXP操作符,正則表達(dá)式可以使用任何下述特殊字符和結(jié)構(gòu):
      ? ^
      匹配字符串的開始部分。
      mysql> SELECT 'fo\nfo' REGEXP '^fo$'; -> 0
      mysql> SELECT 'fofo' REGEXP '^fo'; -> 1
      ? $
      匹配字符串的結(jié)束部分。
      mysql> SELECT 'fo\no' REGEXP '^fo\no$'; -> 1
      mysql> SELECT 'fo\no' REGEXP '^fo$'; -> 0
      ? .
      匹配任何字符(包括回車和新行)。
      mysql> SELECT 'fofo' REGEXP '^f.*$'; -> 1
      mysql> SELECT 'fo\r\nfo' REGEXP '^f.*$'; -> 1
      ? a*
      匹配0或多個(gè)a字符的任何序列。
      mysql> SELECT 'Ban' REGEXP '^Ba*n'; -> 1
      mysql> SELECT 'Baaan' REGEXP '^Ba*n'; -> 1
      mysql> SELECT 'Bn' REGEXP '^Ba*n'; -> 1
      ? a+
      匹配1個(gè)或多個(gè)a字符的任何序列。
      mysql> SELECT 'Ban' REGEXP '^Ba+n'; -> 1
      mysql> SELECT 'Bn' REGEXP '^Ba+n'; -> 0
      ? a?
      匹配0個(gè)或1個(gè)a字符。
      mysql> SELECT 'Bn' REGEXP '^Ba?n'; -> 1
      mysql> SELECT 'Ban' REGEXP '^Ba?n'; -> 1
      mysql> SELECT 'Baan' REGEXP '^Ba?n'; -> 0
      ? de|abc
      匹配序列de或abc。
      mysql> SELECT 'pi' REGEXP 'pi|apa'; -> 1
      mysql> SELECT 'axe' REGEXP 'pi|apa'; -> 0
      mysql> SELECT 'apa' REGEXP 'pi|apa'; -> 1
      mysql> SELECT 'apa' REGEXP '^(pi|apa)$'; -> 1
      mysql> SELECT 'pi' REGEXP '^(pi|apa)$'; -> 1
      mysql> SELECT 'pix' REGEXP '^(pi|apa)$'; -> 0
      ? (abc)*
      匹配序列abc的0個(gè)或多個(gè)實(shí)例。
      mysql> SELECT 'pi' REGEXP '^(pi)*$'; -> 1
      mysql> SELECT 'pip' REGEXP '^(pi)*$'; -> 0
      mysql> SELECT 'pipi' REGEXP '^(pi)*$'; -> 1
      ? {1}, {2,3}
      {n}或{m,n}符號(hào)提供了編寫正則表達(dá)式的更通用方式,能夠匹配模式的很多前述原子(或“部分”)。m和n均為整數(shù)。
      o a*
      可被寫入為a{0,}。
      o a+
      可被寫入為a{1,}。
      o a?
      可被寫入為a{0,1}。
      更準(zhǔn)確地講,a{n}與a的n個(gè)實(shí)例準(zhǔn)確匹配。a{n,}匹配a的n個(gè)或更多實(shí)例。a{m,n}匹配a的m~n個(gè)實(shí)例,包含m和n。
      m和n必須位于0~RE_DUP_MAX(默認(rèn)為255)的范圍內(nèi),包含0和RE_DUP_MAX。如果同時(shí)給定了m和n,m必須小于或等于n。
      mysql> SELECT 'abcde' REGEXP 'a[bcd]{2}e'; -> 0
      mysql> SELECT 'abcde' REGEXP 'a[bcd]{3}e'; -> 1
      mysql> SELECT 'abcde' REGEXP 'a[bcd]{1,10}e'; -> 1
      ? [a-dX], [^a-dX]
      匹配任何是(或不是,如果使用^的話)a、b、c、d或X的字符。兩個(gè)其他字符之間的“-”字符構(gòu)成一個(gè)范圍,與從第1個(gè)字符開始到第2個(gè)字符之間的所有字符匹配。例如,[0-9]匹配任何十進(jìn)制數(shù)字 。要想包含文字字符“]”,它必須緊跟在開括號(hào)“[”之后。要想包含文字字符“-”,它必須首先或最后寫入。對(duì)于[]對(duì)內(nèi)未定義任何特殊含義的任何字符,僅與其本身匹配。
      mysql> SELECT 'aXbc' REGEXP '[a-dXYZ]'; -> 1
      mysql> SELECT 'aXbc' REGEXP '^[a-dXYZ]$'; -> 0
      mysql> SELECT 'aXbc' REGEXP '^[a-dXYZ]+$'; -> 1
      mysql> SELECT 'aXbc' REGEXP '^[^a-dXYZ]+$'; -> 0
      mysql> SELECT 'gheis' REGEXP '^[^a-dXYZ]+$'; -> 1
      mysql> SELECT 'gheisa' REGEXP '^[^a-dXYZ]+$'; -> 0
      ? [.characters.]
      在括號(hào)表達(dá)式中(使用[和]),匹配用于校對(duì)元素的字符序列。字符為單個(gè)字符或諸如新行等字符名。在文件regexp/cname.h中,可找到字符名稱的完整列表。
      mysql> SELECT '~' REGEXP '[[.~.]]'; -> 1
      mysql> SELECT '~' REGEXP '[[.tilde.]]'; -> 1
      ? [=character_class=]
      在括號(hào)表達(dá)式中(使用[和]),[=character_class=]表示等同類。它與具有相同校對(duì)值的所有字符匹配,包括它本身,例如,如果o和(+)均是等同類的成員,那么[[=o=]]、[[=(+)=]]和[o(+)]是同義詞。等同類不得用作范圍的端點(diǎn)。
      ? [:character_class:]
      在括號(hào)表達(dá)式中(使用[和]),[:character_class:]表示與術(shù)語(yǔ)類的所有字符匹配的字符類。標(biāo)準(zhǔn)的類名稱是:
      alnum 文字?jǐn)?shù)字字符
      alpha 文字字符
      blank 空白字符
      cntrl 控制字符
      digit 數(shù)字字符
      graph 圖形字符
      lower 小寫文字字符
      print 圖形或空格字符
      punct 標(biāo)點(diǎn)字符
      space 空格、制表符、新行、和回車
      upper 大寫文字字符
      xdigit 十六進(jìn)制數(shù)字字符
      它們代表在ctype(3)手冊(cè)頁(yè)面中定義的字符類。特定地區(qū)可能會(huì)提供其他類名。字符類不得用作范圍的端點(diǎn)。
      mysql> SELECT 'justalnums' REGEXP '[[:alnum:]]+'; -> 1
      mysql> SELECT '!!' REGEXP '[[:alnum:]]+'; -> 0
      ? [[:<:]], [[:>:]]
      這些標(biāo)記表示word邊界。它們分別與word的開始和結(jié)束匹配。word是一系列字字符,其前面和后面均沒有字字符。字字符是alnum類中的字母數(shù)字字符或下劃線(_)。
      mysql> SELECT 'a word a' REGEXP '[[:<:]]word[[:>:]]'; -> 1
      mysql> SELECT 'a xword a' REGEXP '[[:<:]]word[[:>:]]'; -> 0
      要想在正則表達(dá)式中使用特殊字符的文字實(shí)例,應(yīng)在其前面加上2個(gè)反斜杠“\”字符。MySQL解析程序負(fù)責(zé)解釋其中一個(gè),正則表達(dá)式庫(kù)負(fù)責(zé)解釋另一個(gè)。例如,要想與包含特殊字符“+”的字符串“1+2”匹配,在下面的正則表達(dá)式中,只有最后一個(gè)是正確的:
      mysql> SELECT '1+2' REGEXP '1+2'; -> 0
      mysql> SELECT '1+2' REGEXP '1\+2'; -> 0
      mysql> SELECT '1+2' REGEXP '1\\+2'; -> 1
      
      這是MySQL參考手冊(cè)的翻譯版本,關(guān)于MySQL參考手冊(cè),請(qǐng)?jiān)L問dev.mysql.com。原始參考手冊(cè)為英文版,與英文版參考手冊(cè)相比,本翻譯版可能不是最新的。
      
      第7章 創(chuàng)建計(jì)算字段
      7.1 計(jì)算字段
      計(jì)算字段并不是實(shí)際存在出數(shù)據(jù)庫(kù)中。計(jì)算字段是運(yùn)行時(shí)在SELECT語(yǔ)句中創(chuàng)建的。
      字段(field)與列(column):數(shù)據(jù)庫(kù)中一般稱為列(column),而術(shù)語(yǔ)字段(field)通常用在計(jì)算字段的連接上。
      7.2 拼接字段
      拼接(concatenate):將值聯(lián)接到一起構(gòu)成單個(gè)值。操作符根據(jù)不同的DBMS而有差異。
      Oracle、DB2、Sybase使用||。
      SQL Server和Sybase使用加號(hào)(+)。
      MySQL使用CONCAT函數(shù)(拼接函數(shù)concatenate)。
      
      mysql> select CONCAT(vend_name ,' (',vend_country,')')
       -> from vendors;
      
      +------------------------------------------+
      | concat(vend_name ,' (',vend_country,')') |
      +------------------------------------------+
      | Bear Emporium (USA) |
      | Bears R Us (USA) |
      | Doll House Inc. (USA) |
      | Fun and Games (England) |
      | Furball Inc. (USA) |
      | Jouets et ours (France) |
      +------------------------------------------+
      6 rows in set (0.00 sec)
      
      TRIM函數(shù):去掉空格(略)
      
      使用別名,關(guān)鍵詞為AS(也可省略)。
      mysql> select concat(vend_name ,' (',vend_country,')') AS vend_title
       -> from vendors;
      +-------------------------+
      | vend_title |
      +-------------------------+
      | Bear Emporium (USA) |
      | Bears R Us (USA) |
      | Doll House Inc. (USA) |
      | Fun and Games (England) |
      | Furball Inc. (USA) |
      | Jouets et ours (France) |
      +-------------------------+
      6 rows in set (0.00 sec)
      
      mysql> select concat(vend_name ,' (',vend_country,')') vend_title
       -> from vendors;
      +-------------------------+
      | vend_title |
      +-------------------------+
      | Bear Emporium (USA) |
      | Bears R Us (USA) |
      | Doll House Inc. (USA) |
      | Fun and Games (England) |
      | Furball Inc. (USA) |
      | Jouets et ours (France) |
      +-------------------------+
      6 rows in set (0.00 sec)
      
      注意:別名一般是一個(gè)單詞(可用下劃線連接多個(gè)單詞組成)。
      7.3 執(zhí)行算術(shù)計(jì)算
      SQL算術(shù)操作符
      +
      -
      *
      /
      
      
      第8章 使用數(shù)據(jù)處理函數(shù)
      8.1 函數(shù)
      與幾乎所有的DBMS都同等地支持SQL語(yǔ)句不同,每一個(gè)DBMS都有特定的函數(shù)。
      所以,SQL函數(shù)是不可移植的。
      可移植(portable):所編寫的代碼可以在多個(gè)系統(tǒng)上運(yùn)行。
      
      注意:是否應(yīng)該使用函數(shù)?如果你決定使用函數(shù),應(yīng)該保證做好代碼注釋,以便以后你(或者其他人)能確切的知道所編寫SQL代碼的含義。
      8.2 使用函數(shù)
      8.2.1 文本處理函數(shù)
      函數(shù) 說(shuō)明
      LEFT( )
      LENGTH( )
      LOWER( )
      LTRIM( )
      RTRIM( )
      RIGHT( )
      SOUNDEX( ) 語(yǔ)音匹配
      UPPER( )
      
      mysql> select upper( vend_name)
       -> from vendors;
      +-------------------+
      | upper( vend_name) |
      +-------------------+
      | BEAR EMPORIUM |
      | BEARS R US |
      | DOLL HOUSE INC. |
      | FUN AND GAMES |
      | FURBALL INC. |
      | JOUETS ET OURS |
      +-------------------+
      6 rows in set (0.00 sec)
      8.2.2 日期和時(shí)間處理函數(shù)
       Oracle mysql
      日期函數(shù) SQL> select sysdate from dual; mysql> select now();
      mysql> select sysdate();
      mysql> select curdate();
      mysql> select current_date;
      mysql> select curtime();
      mysql> select current_time;
      日期格式化 SQL> select to_char(sysdate,'yyyy-mm-dd') from dual;
      SQL> select to_char(sysdate,'hh24-mi-ss') from dual; mysql> select date_format(now(),'%Y-%m-%d');
      mysql> select time_format(now(),'%H-%i-%S');
      
      mysql> select order_date
       -> from orders;
      +---------------------+
      | order_date |
      +---------------------+
      | 2004-05-01 00:00:00 |
      | 2004-01-12 00:00:00 |
      | 2004-01-30 00:00:00 |
      | 2004-02-03 00:00:00 |
      | 2004-02-08 00:00:00 |
      +---------------------+
      5 rows in set (0.00 sec)
      
      mysql> select order_date
       -> from orders
       -> where month(order_date) = 02;
      +---------------------+
      | order_date |
      +---------------------+
      | 2004-02-03 00:00:00 |
      | 2004-02-08 00:00:00 |
      +---------------------+
      2 rows in set (0.00 sec)
      
      mysql> select order_date
       -> from orders
       -> where date_format(order_date, '%m') = 02;
      +---------------------+
      | order_date |
      +---------------------+
      | 2004-02-03 00:00:00 |
      | 2004-02-08 00:00:00 |
      +---------------------+
      2 rows in set (0.00 sec)
      8.2.3 數(shù)值處理函數(shù)
      在主要DBMS函數(shù)中,數(shù)值函數(shù)的統(tǒng)一性最高。
      函數(shù) 說(shuō)明
      ABS( ) 絕對(duì)值
      COS( )
      EXP( ) 指數(shù)值
      PI( ) 圓周率
      SIN( )
      SQRT( ) 平方根
      TAN( )
      
      第9章 匯總數(shù)據(jù)
      9.1 聚集函數(shù)
      聚集函數(shù)(aggregate function):從多個(gè)輸入行中計(jì)算,并返回單個(gè)值的函數(shù)。
      
      SQL聚集函數(shù)
      AVG( )
      COUNT( )
      MAX( )
      MIN( )
      SUM( )
      
      COUNT( )函數(shù)有兩種使用方式:
      1、使用COUNT(*)對(duì)表中行的數(shù)據(jù)進(jìn)行計(jì)數(shù),不管表的列中包含的是空值(NULL)還是非空值。
      2、使用COUNT(column)對(duì)特定列中具有值的行進(jìn)行計(jì)數(shù),忽略空值(NULL)。
      9.2 聚集不同值
      DISTINCT參數(shù):只包含不同的值。
      9.3 組合聚集函數(shù)
      (略)
      第10章 分組數(shù)據(jù)
      10.1 數(shù)據(jù)分組
      分組允許把數(shù)據(jù)分為多個(gè)邏輯組,以便能對(duì)每個(gè)組進(jìn)行聚集計(jì)算。
      10.2 創(chuàng)建分組
      分組在SELECT語(yǔ)句的GROUP BY子句中創(chuàng)建。
      mysql> select vend_id, count(*) num_prods
       -> from products
       -> group by vend_id;
      +---------+-----------+
      | vend_id | num_prods |
      +---------+-----------+
      | BRS01 | 3 |
      | DLL01 | 4 |
      | FNG01 | 2 |
      +---------+-----------+
      3 rows in set (0.00 sec)
      
      mysql> select vend_id
       -> from products;
      +---------+
      | vend_id |
      +---------+
      | BRS01 |
      | BRS01 |
      | BRS01 |
      | DLL01 |
      | DLL01 |
      | DLL01 |
      | DLL01 |
      | FNG01 |
      | FNG01 |
      +---------+
      9 rows in set (0.00 sec)
      
      mysql> select vend_id
       -> from products
       -> group by vend_id;
      +---------+
      | vend_id |
      +---------+
      | BRS01 |
      | DLL01 |
      | FNG01 |
      +---------+
      3 rows in set (0.00 sec)
      
      注意:除聚集語(yǔ)句外,SELECT語(yǔ)句中的每個(gè)列都必須在GROUP BY子句中給出。
      下面是一個(gè)反例:
      mysql> select prod_name, count(*) num_prods
       -> from products
       -> group by vend_id;
      +-------------------+-----------+
      | prod_name | num_prods |
      +-------------------+-----------+
      | 8 inch teddy bear | 3 |
      | Fish bean bag toy | 4 |
      | King doll | 2 |
      +-------------------+-----------+
      3 rows in set (0.00 sec)
      輸出結(jié)果沒有意義。
      
      mysql> select vend_id, prod_name
       -> from products;
      +---------+---------------------+
      | vend_id | prod_name |
      +---------+---------------------+
      | DLL01 | Fish bean bag toy |
      | DLL01 | Bird bean bag toy |
      | DLL01 | Rabbit bean bag toy |
      | BRS01 | 8 inch teddy bear |
      | BRS01 | 12 inch teddy bear |
      | BRS01 | 18 inch teddy bear |
      | DLL01 | Raggedy Ann |
      | FNG01 | King doll |
      | FNG01 | Queen doll |
      +---------+---------------------+
      9 rows in set (0.00 sec)
      10.3 過濾分組
      WHERE過濾行,而HAVING過濾分組。
      HAVING支持所有的WHERE操作符。
      注意:HAVING和WHERE的差別,WHERE在數(shù)據(jù)分組前進(jìn)行過濾,HAVING在數(shù)據(jù)分組后進(jìn)行過濾。也就是說(shuō),WHERE排出的行不包括在分組中。
      mysql> select vend_id, count(*) num_prods
       -> from products
       -> group by vend_id
       -> having count(*) >= 3;
      +---------+-----------+
      | vend_id | num_prods |
      +---------+-----------+
      | BRS01 | 3 |
      | DLL01 | 4 |
      +---------+-----------+
      2 rows in set (0.00 sec)
      
      HAVING和WHERE同時(shí)出現(xiàn):
      mysql> select vend_id, count(*) num_prods
       -> from products
       -> where prod_price >=4
       -> group by vend_id
       -> having count(*) >=2;
      +---------+-----------+
      | vend_id | num_prods |
      +---------+-----------+
      | BRS01 | 3 |
      | FNG01 | 2 |
      +---------+-----------+
      2 rows in set (0.00 sec)
      
      mysql> select vend_id, count(*) num_prods
       -> from products
       -> group by vend_id;
      +---------+-----------+
      | vend_id | num_prods |
      +---------+-----------+
      | BRS01 | 3 |
      | DLL01 | 4 |
      | FNG01 | 2 |
      +---------+-----------+
      3 rows in set (0.00 sec)
      10.4 分組和排序
      GROUP BY的輸出可能排序,也可能不排序。保證數(shù)據(jù)正確排序的方法是使用ORDER BY子句。
      10.5 SELECT子句順序
      SELECT
      FROM
      WHERE
      GROUP BY
      HAVING
      ORDER BY
      第11章 使用子查詢
      11.1 子查詢
      查詢(query):任何SQL語(yǔ)句都是查詢。但此術(shù)語(yǔ)一般指SELECT語(yǔ)句。
      子查詢(subquery):嵌套在其他查詢中的查詢。
      11.2 利用子查詢進(jìn)行過濾
      格式化SQL:可以把子查詢分解為多行,并適當(dāng)?shù)倪M(jìn)行縮進(jìn)。
      
      注意:作為子查詢的SELECT語(yǔ)句只能查詢(返回)單個(gè)列。企圖檢索多個(gè)列將返回錯(cuò)誤。
     ?。ɡ勇裕?br />   11.3 作為計(jì)算字段使用子查詢
      (例子略)
      第12章 聯(lián)結(jié)表(join table)
      12.1 聯(lián)結(jié)
      聯(lián)結(jié)(join):join常見不規(guī)范譯法還有“聯(lián)接”、“連接”。
      12.1.1 關(guān)系表
      理解關(guān)系表的最好方法是來(lái)看一個(gè)現(xiàn)實(shí)世界中的例子。
      作者寫得非常好,是我見過的最通俗易懂的!中文暫時(shí)略
      英文如下:
      The best way to understand relational tables is to look at a real-world example.
      Suppose you had a database table containing a product catalog, with each catalog item in its own row. The kind of information you would store with each item would include a product description and price, along with vendor information about the company that creates the product.
      Now suppose that you had multiple catalog items created by the same vendor. Where would you store the vendor information (things like vendor name, address, and contact information)? You wouldn't want to store that data along with the products for several reasons:
      Because the vendor information is the same for each product that vendor produces, repeating the information for each product is a waste of time and storage space.
      If vendor information changes (for example, if the vendor moves or his area code changes), you would need to update every occurrence of the vendor information.
      When data is repeated (that is, the vendor information is used with each product), there is a high likelihood that the data will not be entered exactly the same way each time. Inconsistent data is extremely difficult to use in reporting.
      The key here is that having multiple occurrences of the same data is never a good thing, and that principle is the basis for relational database design. Relational tables are designed so that information is split into multiple tables, one for each data type. The tables are related to each other through common values (and thus the relational in relational design).
      In our example, you can create two tables, one for vendor information and one for product information. The Vendors table contains all the vendor information, one table row per vendor, along with a unique identifier for each vendor. This value, called a primary key, can be a vendor ID, or any other unique value.
      The Products table stores only product information, and no vendor specific information other than the vendor ID (the Vendors table's primary key). This key relates the Vendors table to the Products table, and using this vendor ID enables you to use the Vendors table to find the details about the appropriate vendor.
      What does this do for you? Well, consider the following:
      Vendor information is never repeated, and so time and space are not wasted.
      If vendor information changes, you can update a single record, the one in the Vendors table. Data in related tables does not change.
      As no data is repeated, the data used is obviously consistent, making data reporting and manipulation much simpler.
      The bottom line is that relational data can be stored efficiently and manipulated easily. Because of this, relational databases scale far better than nonrelational databases.
      
      Scale Able to handle an increasing load without failing. A well-designed database or application is said to scale well.
      
      
      Why Use Joins?
      As just explained, breaking data into multiple tables enables more efficient storage, easier manipulation, and greater scalability. But these benefits come with a price.
      If data is stored in multiple tables, how can you retrieve that data with a single SELECT statement?
      The answer is to use a join. Simply put, a join is a mechanism used to associate tables within a SELECT statement (and thus the name join). Using a special syntax, multiple tables can be joined so that a single set of output is returned, and the join associates the correct rows in each table on-the-fly.
      
      Using Interactive DBMS Tools It is important to understand that a join is not a physical entity—in other words, it does not exist in the actual database tables. A join is created by the DBMS as needed, and it persists for the duration of the query execution.
      Many DBMSs provide graphical interfaces that can be used to define table relationships interactively. These tools can be invaluable in helping to maintain referential integrity. When using relational tables, it is important that only valid data is inserted into relational columns. Going back to the example, if an invalid vendor ID is stored in the Products table, those products would be inaccessible because they would not be related to any vendor. To prevent this from occurring, the database can be instructed to only allow valid values (ones present in the Vendors table) in the vendor ID column in the Products table. Referential integrity means that the DBMS enforces data integrity rules. And these rules are often managed through DBMS provided interfaces.
      
      12.2 創(chuàng)建聯(lián)結(jié)
      mysql> select vend_name, prod_name, prod_price
       -> from vendors, products
       -> where vendors.vend_id = products.vend_id;
      +-----------------+---------------------+------------+
      | vend_name | prod_name | prod_price |
      +-----------------+---------------------+------------+
      | Bears R Us | 8 inch teddy bear | 5.99 |
      | Bears R Us | 12 inch teddy bear | 8.99 |
      | Bears R Us | 18 inch teddy bear | 11.99 |
      | Doll House Inc. | Fish bean bag toy | 3.49 |
      | Doll House Inc. | Bird bean bag toy | 3.49 |
      | Doll House Inc. | Rabbit bean bag toy | 3.49 |
      | Doll House Inc. | Raggedy Ann | 4.99 |
      | Fun and Games | King doll | 9.49 |
      | Fun and Games | Queen doll | 9.49 |
      +-----------------+---------------------+------------+
      9 rows in set (0.03 sec)
      
      笛卡爾積(cartesian product):由沒有連接條件的表關(guān)系返回的結(jié)果為笛卡爾積。檢索出的行數(shù)是第一個(gè)表的行數(shù)乘以第二個(gè)表的行數(shù)。
      為了理解這一點(diǎn),請(qǐng)看沒有連接條件的SELECT語(yǔ)句及輸出。
      mysql> select vend_name, prod_name, prod_price
       -> from vendors, products;
      +-----------------+---------------------+------------+
      | vend_name | prod_name | prod_price |
      +-----------------+---------------------+------------+
      | Bear Emporium | Fish bean bag toy | 3.49 |
      | Bears R Us | Fish bean bag toy | 3.49 |
      | Doll House Inc. | Fish bean bag toy | 3.49 |
      | Fun and Games | Fish bean bag toy | 3.49 |
      | Furball Inc. | Fish bean bag toy | 3.49 |
      | Jouets et ours | Fish bean bag toy | 3.49 |
      | Bear Emporium | Bird bean bag toy | 3.49 |
      | Bears R Us | Bird bean bag toy | 3.49 |
      | Doll House Inc. | Bird bean bag toy | 3.49 |
      | Fun and Games | Bird bean bag toy | 3.49 |
      | Furball Inc. | Bird bean bag toy | 3.49 |
      | Jouets et ours | Bird bean bag toy | 3.49 |
      | Bear Emporium | Rabbit bean bag toy | 3.49 |
      | Bears R Us | Rabbit bean bag toy | 3.49 |
      | Doll House Inc. | Rabbit bean bag toy | 3.49 |
      | Fun and Games | Rabbit bean bag toy | 3.49 |
      | Furball Inc. | Rabbit bean bag toy | 3.49 |
      | Jouets et ours | Rabbit bean bag toy | 3.49 |
      | Bear Emporium | 8 inch teddy bear | 5.99 |
      | Bears R Us | 8 inch teddy bear | 5.99 |
      | Doll House Inc. | 8 inch teddy bear | 5.99 |
      | Fun and Games | 8 inch teddy bear | 5.99 |
      | Furball Inc. | 8 inch teddy bear | 5.99 |
      | Jouets et ours | 8 inch teddy bear | 5.99 |
      | Bear Emporium | 12 inch teddy bear | 8.99 |
      | Bears R Us | 12 inch teddy bear | 8.99 |
      | Doll House Inc. | 12 inch teddy bear | 8.99 |
      | Fun and Games | 12 inch teddy bear | 8.99 |
      | Furball Inc. | 12 inch teddy bear | 8.99 |
      | Jouets et ours | 12 inch teddy bear | 8.99 |
      | Bear Emporium | 18 inch teddy bear | 11.99 |
      | Bears R Us | 18 inch teddy bear | 11.99 |
      | Doll House Inc. | 18 inch teddy bear | 11.99 |
      | Fun and Games | 18 inch teddy bear | 11.99 |
      | Furball Inc. | 18 inch teddy bear | 11.99 |
      | Jouets et ours | 18 inch teddy bear | 11.99 |
      | Bear Emporium | Raggedy Ann | 4.99 |
      | Bears R Us | Raggedy Ann | 4.99 |
      | Doll House Inc. | Raggedy Ann | 4.99 |
      | Fun and Games | Raggedy Ann | 4.99 |
      | Furball Inc. | Raggedy Ann | 4.99 |
      | Jouets et ours | Raggedy Ann | 4.99 |
      | Bear Emporium | King doll | 9.49 |
      | Bears R Us | King doll | 9.49 |
      | Doll House Inc. | King doll | 9.49 |
      | Fun and Games | King doll | 9.49 |
      | Furball Inc. | King doll | 9.49 |
      | Jouets et ours | King doll | 9.49 |
      | Bear Emporium | Queen doll | 9.49 |
      | Bears R Us | Queen doll | 9.49 |
      | Doll House Inc. | Queen doll | 9.49 |
      | Fun and Games | Queen doll | 9.49 |
      | Furball Inc. | Queen doll | 9.49 |
      | Jouets et ours | Queen doll | 9.49 |
      +-----------------+---------------------+------------+
      54 rows in set (0.00 sec)
      其中,vendors有6行,products有9行。
      注意:應(yīng)該保證所有的聯(lián)結(jié)都有WHERE子句。
      12.2.2 內(nèi)部聯(lián)結(jié)
      目前為止所用的聯(lián)結(jié)稱為等值聯(lián)結(jié)(equi-join),它基于兩個(gè)表之間的相等測(cè)試。這種聯(lián)結(jié)也稱為內(nèi)部聯(lián)結(jié)。其實(shí),對(duì)于這種聯(lián)結(jié)可以使用稍微不同的語(yǔ)法來(lái)明確指定聯(lián)結(jié)的類型。
      mysql> select vend_name, prod_name, prod_price
       -> from vendors INNER JOIN products
       -> ON vendors.vend_id = products.vend_id;
      “正確的”語(yǔ)法——ANSI SQL規(guī)范首選INNER JOIN語(yǔ)法。
      12.2.3 聯(lián)結(jié)多個(gè)表
      多做實(shí)驗(yàn)——
      第13章 創(chuàng)建高級(jí)聯(lián)結(jié)
      13.1 使用表別名
      mysql> select vend_name, prod_name, prod_price
       -> from vendors v, products p
       -> where v.vend_id = p.vend_id;
      +-----------------+---------------------+------------+
      | vend_name | prod_name | prod_price |
      +-----------------+---------------------+------------+
      | Bears R Us | 8 inch teddy bear | 5.99 |
      | Bears R Us | 12 inch teddy bear | 8.99 |
      | Bears R Us | 18 inch teddy bear | 11.99 |
      | Doll House Inc. | Fish bean bag toy | 3.49 |
      | Doll House Inc. | Bird bean bag toy | 3.49 |
      | Doll House Inc. | Rabbit bean bag toy | 3.49 |
      | Doll House Inc. | Raggedy Ann | 4.99 |
      | Fun and Games | King doll | 9.49 |
      | Fun and Games | Queen doll | 9.49 |
      +-----------------+---------------------+------------+
      9 rows in set (0.00 sec)
      注意:Oracle不支持AS關(guān)鍵詞。
      13.2 使用不同類型的聯(lián)結(jié)
      到現(xiàn)在為止,我們使用的只是成為內(nèi)部聯(lián)結(jié)或等值聯(lián)結(jié)的簡(jiǎn)單聯(lián)結(jié)。下面來(lái)看3中其他聯(lián)結(jié):自聯(lián)結(jié)、自然聯(lián)結(jié)、外聯(lián)結(jié)。
      13.2.1 自聯(lián)結(jié)
      略
      13.2.2 自然聯(lián)結(jié)
      自然聯(lián)結(jié):是每個(gè)列只返回一次,排除多次出現(xiàn)的列。怎樣完成這項(xiàng)工作呢?答案是,系統(tǒng)不完成這項(xiàng)工作,由你自己完成。這一般是對(duì)表使用通配符(select *),對(duì)所有其他表的列使用明確的子集完成的。
      例子略
      13.2.3 外部聯(lián)結(jié)
      目前為止所用的聯(lián)結(jié)稱為等值聯(lián)結(jié)(equi-join),它基于兩個(gè)表之間的相等測(cè)試。這種聯(lián)結(jié)也稱為內(nèi)部聯(lián)結(jié)。
      mysql> select vend_name, prod_name, prod_price
       -> from vendors INNER JOIN products
       -> ON vendors.vend_id = products.vend_id;
      +-----------------+---------------------+------------+
      | vend_name | prod_name | prod_price |
      +-----------------+---------------------+------------+
      | Bears R Us | 8 inch teddy bear | 5.99 |
      | Bears R Us | 12 inch teddy bear | 8.99 |
      | Bears R Us | 18 inch teddy bear | 11.99 |
      | Doll House Inc. | Fish bean bag toy | 3.49 |
      | Doll House Inc. | Bird bean bag toy | 3.49 |
      | Doll House Inc. | Rabbit bean bag toy | 3.49 |
      | Doll House Inc. | Raggedy Ann | 4.99 |
      | Fun and Games | King doll | 9.49 |
      | Fun and Games | Queen doll | 9.49 |
      +-----------------+---------------------+------------+
      9 rows in set (0.03 sec)
      
      與內(nèi)部聯(lián)結(jié)不同,外部聯(lián)結(jié)包括沒有關(guān)聯(lián)的行。下面的例子,LEFT OUTER JOIN選擇from子句左邊表的所有行。(即,列出所有供貨商及其產(chǎn)品,包括沒有提供產(chǎn)品的供貨商,下面一節(jié)——13.3 使用帶聚集函數(shù)的聯(lián)結(jié)中的例子更直接,更好理解。)
      mysql> select vend_name, prod_name, prod_price
       -> from vendors LEFT OUTER JOIN products
       -> ON vendors.vend_id = products.vend_id;
      +-----------------+---------------------+------------+
      | vend_name | prod_name | prod_price |
      +-----------------+---------------------+------------+
      | Bear Emporium | NULL | NULL |
      | Bears R Us | 8 inch teddy bear | 5.99 |
      | Bears R Us | 12 inch teddy bear | 8.99 |
      | Bears R Us | 18 inch teddy bear | 11.99 |
      | Doll House Inc. | Fish bean bag toy | 3.49 |
      | Doll House Inc. | Bird bean bag toy | 3.49 |
      | Doll House Inc. | Rabbit bean bag toy | 3.49 |
      | Doll House Inc. | Raggedy Ann | 4.99 |
      | Fun and Games | King doll | 9.49 |
      | Fun and Games | Queen doll | 9.49 |
      | Furball Inc. | NULL | NULL |
      | Jouets et ours | NULL | NULL |
      +-----------------+---------------------+------------+
      12 rows in set (0.00 sec)
      13.3 使用帶聚集函數(shù)的聯(lián)結(jié)
      對(duì)供貨商的產(chǎn)品進(jìn)行計(jì)數(shù)
      mysql> select vend_name, count(prod_name)
       -> from vendors INNER JOIN products
       -> ON vendors.vend_id = products.vend_id
       -> group by vend_name;
      +-----------------+------------------+
      | vend_name | count(prod_name) |
      +-----------------+------------------+
      | Bears R Us | 3 |
      | Doll House Inc. | 4 |
      | Fun and Games | 2 |
      +-----------------+------------------+
      3 rows in set (0.00 sec)
      
      對(duì)供貨商的產(chǎn)品進(jìn)行計(jì)數(shù),包括沒有提供產(chǎn)品的供貨商。
      mysql> select vend_name, count(prod_name)
       -> from vendors LEFT OUTER JOIN products
       -> ON vendors.ven
  •     花了兩個(gè)下午讀完了這本書,感覺內(nèi)容比較淺,沒有什么太深?yuàn)W和太思想的東西。當(dāng)工具書感覺有些介紹的還不是很全,不過感覺初學(xué)SQL的可以讀讀,易讀性比較高,另外介紹的東西也都是很基礎(chǔ)的知識(shí),感覺覺的不太重要,但是不懂還不行,就是一盤清口的小菜,雖然吃不飽,但吃完會(huì)讓你吃正餐的時(shí)候更舒服。
  •     第一感覺比較貴哈,但是這本書能淺顯地告訴我一些我一直以來(lái)比較模糊的概念,而且能增加我學(xué)習(xí)sql的信心,推薦。
  •     知道這本書是從一個(gè)推薦里看到的,覺得很不錯(cuò),仔細(xì)的看了一遍。
      可惜我覺得我要學(xué)SQL還是一個(gè)漫長(zhǎng)的過程。
      忽然想,大學(xué)那會(huì)兒真該學(xué)IT的。。。。
  •     《SQL必知必會(huì)(第3版)》剛買來(lái)的時(shí)候就非常驚訝--居然這一200頁(yè)不到的小本本定的市場(chǎng)價(jià)是29元,32開的handbook可方便隨身帶,買來(lái)后一口氣就閱讀到了第七章,大呼過癮。里面的內(nèi)容是以前知道但沒有理解,但沒有像這本書這么教得通俗易懂的,如形容數(shù)據(jù)表就像是一個(gè)文件夾,數(shù)據(jù)庫(kù)實(shí)例就像是一個(gè)文件柜這樣容易理解。
      
      這本書的原作者寫得不錯(cuò),翻譯的水平也極佳。這本書的定位是入門,所以一切都以點(diǎn)到就為止了。比如存儲(chǔ)過程那一章原作者就說(shuō)了只以簡(jiǎn)單的講一講。我們平時(shí)實(shí)際工作中寫得就復(fù)雜多了 。而且原作者把各種主流DBMS的區(qū)別與一般常見的實(shí)踐技巧全部傳授給了你,我們這樣的 SQL 菜鳥不正需要這些知識(shí)嗎?
  •     以前由于工作的緣故,要經(jīng)常使用SQL語(yǔ)言去操作數(shù)據(jù)庫(kù),很多東西記不住,或者記憶很模糊,查查這本書就可以了,適合入門的數(shù)據(jù)庫(kù)操作員,不錯(cuò)的工具手冊(cè)。
  •     這本書買來(lái)兩個(gè)禮拜,認(rèn)真地把我懂得的部分看完了,不懂得的部分還在努力在看……
      總體來(lái)說(shuō),這本書很適合入門。
  •     名副其實(shí),書中的內(nèi)容的確是關(guān)系型數(shù)據(jù)庫(kù)使用者“必須知道必須會(huì)”的,如果你連這些都不知道,那就太……
      這本書講得實(shí)在有夠淺,只適合徹底的新手和入門者。而對(duì)于一個(gè)有SQL使用經(jīng)驗(yàn)的人來(lái)說(shuō),本書前17章和20、22章的內(nèi)容你一定了如指掌;如果你對(duì)18、 19、21章講解的視圖、存儲(chǔ)過程和游標(biāo)功能很陌生,那么你一定和我一樣是古老的MySQL4.0的使用者——這個(gè)版本不支持這三種功能。
      如果你是新手的話,這本書還是值得一買的,內(nèi)容淺顯易懂,能幫你很快入門,薄薄一本小冊(cè)子讀起來(lái)也很快(原書名直譯過來(lái)是“SQL 10分鐘入門”)。
      如果你已經(jīng)使用SQL有一段時(shí)間了,那么,還是去尋找更高階的教程吧。
  •   如果希望了解數(shù)據(jù)庫(kù)的原理和設(shè)計(jì),個(gè)人推薦《SQL權(quán)威指南》http://book.douban.com/subject/20395440/
  •   書名又不是關(guān)系型數(shù)據(jù)庫(kù)原理,會(huì)介紹原理和設(shè)計(jì)才怪了
  •   書名必知必會(huì)么,寫給所有杰出SQL數(shù)據(jù)庫(kù)人看的,顯然不可能有高深的內(nèi)容
  •   比較好的面試佛腳書吧
 

250萬(wàn)本中文圖書簡(jiǎn)介、評(píng)論、評(píng)分,PDF格式免費(fèi)下載。 第一圖書網(wǎng) 手機(jī)版

京ICP備13047387號(hào)-7