- 1、本文档共40页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
More SQL Database Modification Controlling Concurrent Behavior Database Modifications A modification command does not return a result (as a query does), but changes the database in some way. Three kinds of modifications: Insert a tuple or tuples. Delete a tuple or tuples. Update the value(s) of an existing tuple or tuples. Insertion To insert a single tuple: INSERT INTO relation VALUES ( list of values ); Example: add to Likes(drinker, beer) the fact that Sally likes Bud. INSERT INTO Likes VALUES(’Sally’, ’Bud’); Specifying Attributes in INSERT We may add to the relation name a list of attributes. Two reasons to do so: We forget the standard order of attributes for the relation. We don’t have values for all attributes, and we want the system to fill in missing components with NULL or a default value. Example: Specifying Attributes Another way to add the fact that Sally likes Bud to Likes(drinker, beer): INSERT INTO Likes(beer, drinker) VALUES(’Bud’, ’Sally’); Inserting Many Tuples We may insert the entire result of a query into a relation, using the form: INSERT INTO relation ( subquery ); Example: Insert a Subquery Using Frequents(drinker, bar), enter into the new relation PotBuddies(name) all of Sally’s “potential buddies,” i.e., those drinkers who frequent at least one bar that Sally also frequents. Solution INSERT INTO PotBuddies (SELECT d2.drinker FROM Frequents d1, Frequents d2 WHERE d1.drinker = ’Sally’ AND d2.drinker ’Sally’ AND d1.bar = d2.bar ); Deletion To delete tuples satisfying a condition from some relation: DELETE FROM relation WHERE condition; Example: Deletion Delete from Likes(drinker, beer) the fact that Sally likes Bud: Example: Delete all Tuples Make the relation Likes empty: Example: Delete Many Tuples Delete from Beers(name, manf) all beers for which there is another beer by the same manufacturer. Semantics of Deletion --- (1) Suppose Anheuser-Busch makes only Bud and Bud Lite. Suppose we come to the tuple b for Bu
您可能关注的文档
最近下载
- 中医经方临床运用培训课件.ppt
- 汽车装配与调试技术课程标准.docx
- 毕业论文低频电涡流传感器测量电路设计.doc
- S2168001-社会计算导论-智算学部.pptx
- 《古建筑修缮工程施工规程》.pdf
- 对企业有利的劳动合同.docx
- 班主任带班育人方略《做有温度的班主任》宣讲演讲PPT课件.pptx
- 答案-国开电大(本科)《当代中国政治制度》在线形考(形考任务二)试题.docx
- 大学物理 II-(热学、振动和波、光学、量子)(北京交大)中国大学MOOC慕课 章节测验期末考试客观题答案.docx
- 【专项复习】2024年小学六年级下册小升初数学专题复习(8)比的性质求比值和化简比及比的应用(知识归纳+典例精析+拔高训练)(1).docx
文档评论(0)