数据库原理 第4章 SQL课件.ppt

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据库原理 第4章 SQL课件

Chapter 4: SQL;Schema Used in Examples 示例用的模式;Basic Structure 基本结构;The select Clause select子句;;The select Clause (Cont.);The where Clause ;The where Clause (Cont.);The from Clause;The Rename Operation 更名运算 ;;Tuple Variables 元组变量;;String Operations 字符串操作;;Ordering the Display of Tuples 元组显示排序;;Duplicates 重复;Duplicates (Cont.);Set Operations 集合运算;Find all customers who have a loan, an account, or both: (select customer-name from depositor) union (select customer-name from borrower) 如果一个叫Jones的客户在银行中有几个帐户或贷款(或两者都有),Jones在结果中也只出现一次。 union all:如果Jones在银行中有三个帐户和两笔贷款,那么Jones在结果中出现五次。 Find all customers who have both a loan and an account. (select customer-name from depositor) intersect (select customer-name from borrower) 如果一个叫Jones的客户在银行中有几个帐户和贷款,Jones在结果中也只出现一次。 intersect all:如果Jones在银行中有三个帐户和两笔贷款,那么Jones在结果中出现两次。 Find all customers who have an account but no loan. (select customer-name from depositor) except (select customer-name from borrower) 仅当Jones在银行中有帐户但无贷款时,那么Jones在结果中出现且只出现一次。 except all:如果Jones在银行中有三个帐户和两笔贷款,那么Jones在结果中出现一次。但若Jones在银行中有两个帐户和三笔贷款,那么Jones在结果中不出现。 ;Aggregate Functions;Aggregate Functions – Group By;Aggregate Functions – Having Clause;Find the number of tuples in the customer relation. select count (*) from customer Find the average balance for each customer who lives in Harrison and has at least three accounts. Account-schema=(branch-name, account-number, balance) Depositor-schema=(customer-name, account-number) Customer -schema=(customer-name, customer-street,customer-city) select depositor.customer-name, avg (balance) from depositor,account,customer where depositor.account-number = account.account-number and depositor. customer-name=customer. customer-name and customer-city=‘Harrison’ group by depositor. customer-name having count (distinct depositor.account-number ) =3 ;Null Values;Null Values and Three Valued Logic

文档评论(0)

gm8099 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档