【正文】
? SELECT type, AVG(price), SUM(price), COUNT(*) FROM titles WHERE price$10 GROUP BY type 使用 HAVING ? SELECT type, AVG(price), SUM(price), COUNT(*) ? FROM titles ? WHERE price$10 ? GROUP BY type ? HAVING AVG(price)$20 使用 HAVING 36 (8) 多表查詢 ? ( a) 笛卡爾乘積 ? SELECT title_id, au_fname FROM titles, authors ? ? SELECT , , FROM titles, titleauthor 37 ( b ) 別名 ? SELECT , , FROM titles t, titleauthor ta ? ? SELECT , , FROM titles t, titleauthor ta WHERE = 38 ( c) 篩選 ? SELECT , FROM titles t, titleauthor ta, authors a WHERE = and = 39 6 視圖 ? (1) 視圖的定義 ? SQL建立視圖的語句格式為: ? CREATE VIEW 視圖名 [(列名 1[, 列名]… )] AS 查詢 40 ? CREATE VIEW au_view AS SELECT au_id, au_fname, au_lname FROM authors ? CREATE VIEW author_title AS SELECT , FROM titles t, titleauthor ta, authors a WHERE = and = 41 (2)視圖查詢 ? SELECT * ? FROM au_view ? SELECT , ? FROM titles t, titleauthor ta, authors a ? WHERE = and = 42 ( 3) 刪除視圖 ? DROP VIEW 視圖名 ? ? DROP VIEW a_authors 43 索引 ? 索引可以極大地提高查詢的速度 ? 索引可以建在一列或幾列上 ? 有 ASC(升序 )和 DESC(降序 ) ? ( 1) 索引類型 ? 按照存儲位置:聚集索引和非聚集索引 。 ? SQL的數(shù)據(jù)控制語句包括授權(quán) (Grant)、 收權(quán)(Revoke)和拒絕訪問 (Deny)三種,其權(quán)限的設(shè)置對象可以是數(shù)據(jù)庫用戶或用