仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 537|回复: 8
打印 上一主题 下一主题

[学习教程] ASP网页编程之SQL Server Views

[复制链接]
飘灵儿 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 23:10:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
缺乏可以共同遵循的行业标准,ASP还处在发展初期,大家对它的理解不同,如产品和服务标准,收费标准等,不利于行业的健康发展。serverbegin:

SQLServerViews

Postedbyscotton2004年11月28日

AnRDBMSusesaviewtocreateavirtualtable.Thecarefuluseofviewscanimprovetheinteractionbetweena.NETapplicationandtheunderlyingdata.InthisarticlewewilldiscussviewsinMicrosoftSQLServer,includingbestpracticesforcreatingandusingviews.
InSQLServeraviewrepresentsavirtualtable.Justlikearealtable,aviewconsistsofrowswithcolumns,andyoucanretrievedatafromaview(sometimesevenupdatedatainaview).Thefieldsintheview’svirtualtablearethefieldsofoneormorerealtablesinthedatabase.Youcanuseviewstojointwotablesinyourdatabaseandpresenttheunderlyingdataasifthedatawerecomingfromasingletable,thussimplifyingtheschemaofyourdatabaseforusersperformingad-hocreporting.Youcanalsouseviewsasasecuritymechanismtorestrictthedataavailabletoendusers.Viewscanalsoaggregatedata(particularlyusefulifyoucantakeadvantageofindexedviews),andhelppartitiondata.Inthisarticlewewilllookatthesedifferenttypesofviewtoseewhenwecantakeadvantageofaviewforourapplication.


SampleView
ThesampledatabaseNorthwindinSQLServerhasanumberofviewsinstalledbydefault.Oneexampleisthe“CurrentProductList”view,shownhere.


SELECT
Product_List.ProductID,Product_List.ProductName
FROM
ProductsASProduct_List
WHERE(Product_List.Discontinued=0)


FrominsideanapplicationwecanissuethefollowingSQLquerytoretrieveasetofrecordsrepresentingactiveproducts.


SELECTProductID,ProductNamefrom[CurrentProductList]


TheviewhascreatedanewvirtualtablebyusingrecordsfromtheProductstableandapplyingasmallpieceoflogic(afilterontheDiscontinuedfield).Youcouldusetheviewinsideofaqueryfromyourapplication,orastoredprocedure,orevenfrominsideanotherview.Viewsareasimplebutpowerfulabstraction.Youcanpushquerycomplexity,likefilterandjoinstatements,intoaviewtopresentasimplermodelofthedatawithoutsacrificingthedatabasedesignorintegrity.

Weoftendescribeaviewasavirtualtablebecausethedatabasedoesnotstoretheviewdata.Instead,whenweretrievedatafromaviewthedatabaseenginerecreatesthedatausingtheSELECTstatementsintheview’sdefinition.Sincethedatabaseonlystoresadefinitionoftheview,andnotthedata,thereisnosignificantcostinspaceforusingaview,althoughthereisanexceptiontothisrulewewilldiscusslaterinthearticle.NotealsothatthedatabaseenginesqueryoptimizercanoftencombinethedefinitionoftheviewwiththeSQLqueriesinteractingwiththeviewtoprovideanefficientqueryplan(inotherwords,thedatabaseenginemightnotneedtoperformtheentireSELECToperationintheviewifitknowstheouterquerywillfilteroutadditionalrecords).


WhenToUseAView

Youneedtohaveagoalinmindwhencreatingaview.Thereareanumberofscenarioswhereyouwillwanttolookforaviewasasolution.
Tohidethecomplexityoftheunderlyingdatabaseschema,orcustomizethedataandschemaforasetofusers.
Tocontrolaccesstorowsandcolumnsofdata.
Toaggregatedataforperformance.
Let’stakealookateachofthesescenarios.


ComplexityandCustomization
Takingcareofcomplexjoinsandfilteringrulesinsideofaviewcanbenefitotherusers.Asanexample,considerthefollowingviewfromtheNorthwinddatabase.


CREATEVIEW"OrderDetailsExtended"AS
SELECT
"OrderDetails".OrderID,
"OrderDetails".ProductID,
Products.ProductName,
"OrderDetails".UnitPrice,
"OrderDetails".Quantity,
"OrderDetails".Discount,
(CONVERT(money,("OrderDetails".UnitPrice*Quantity*(1-Discount)/100))*100)ASExtendedPrice
FROM
Products
INNERJOIN
"OrderDetails"ON
Products.ProductID="OrderDetails".ProductID


Abusinessuserwithanad-hocreportingtoolcantakeadvantageoftheaboveviewinbuildingcustomizedreportstosupporthergoals.Shecanusetheviewtoseeallofthedetailsaboutanorderwithoutfindingthetablestojoinforproductandorderinformation,andwithoutperformingthecalculationforthepricediscount.Notonlydoesthismakethedatabaseeasierfortheenduser,butitalsoallowsaDBAtomakechangestot</p>强大的可扩展性。ASP具有强大的扩展性,可以实现与多种网络、硬件设备的连接:通过专用的通讯线路远程接入企业;通过远程拨号服务器为远程拨号客户提供服务;通过WAP为移动电话互联网客户服务。
谁可相欹 该用户已被删除
沙发
发表于 2015-1-20 07:53:15 | 只看该作者
用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。
深爱那片海 该用户已被删除
板凳
发表于 2015-1-25 14:38:56 | 只看该作者
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
乐观 该用户已被删除
地板
发表于 2015-1-30 20:47:46 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。
蒙在股里 该用户已被删除
5#
发表于 2015-2-6 15:54:46 | 只看该作者
Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名")
金色的骷髅 该用户已被删除
6#
发表于 2015-2-16 23:21:30 | 只看该作者
运用经典的例子。并且自己可以用他来实现一些简单的系统。如果可以对他进行进一步的修改,找出你觉得可以提高性能的地方,加上自己的设计,那就更上一个层次了,也就会真正地感到有所收获。
小妖女 该用户已被删除
7#
发表于 2015-3-5 12:04:21 | 只看该作者
那么,ASP.Net有哪些改进呢?
透明 该用户已被删除
8#
发表于 2015-3-12 05:34:37 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。
9#
发表于 2015-3-19 18:17:19 | 只看该作者
不能只是将它停留在纸上谈兵的程度上。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-9-28 02:04

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表