MYSQL网站制作之SQL 一些小技能
使用DBaaS能让收入损失从其他业务上得到弥补,如软件更新和硬件管理。也许决定走DBaaS之路的客户可能会跳过解决方案提供商,尽管这个决策看起来有点短视。技能ThesehasbeenpickedupfromthreadwithinsqljunkiesForumshttp://www.sqljunkies.com
Problem
TheproblemisthatIneedtorounddifferently(byhalves)
Example:4.24roundsto4.00,but4.26roundsto4.50.
4.74roundsto4.50and4.76roundsto5.00
Solution
declare@tfloat
set@t=100.74
selectround(@t*2.0,0)/2
Problem
Imwritingafunctionthatneedstotakeinacommaseperatedlistandusitinawhereclause.Theselectwouldlooksomethinglikethis:
select*frompeoplewherefirstnamein(larry,curly,moe)
Solution
usenorthwind
go
declare@xVarvarchar(50)
set@xVar=anne,janet,nancy,andrew,robert
select*fromemployeeswhere@xVarlike%+firstname+%
Problem
Needasimplepagingsqlcommand
Solution
usenorthwind
go
select*fromproductsa
where(selectcount(*)fromproductsbwherea.productid>=b.productid)between15and16
Problem
Performcase-sensitivecomparisionwithinsqlstatementwithouthavingtousetheSETcommand
Solution
usenorhtwind
go
SELECT*FROMproductsASt1
WHEREt1.productnameCOLLATESQL_EBCDIC280_CP1_CS_AS=Chai
--executethiscommandtogetdifferentcollatenaming
--select*from::fn_helpcollations()
Problem
Howtocallastoredprocedurelocatedinadifferentserver
Solution
SETNOCOUNTON
usemaster
go
EXECsp_addlinkedserver172.16.0.22,NSqlServer
go
Execsp_link_publication@publisher=172.16.0.22,
@publisher_db=Northwind,
@publication=NorthWind,@security_mode=2,
@login=sa,@password=sa
go
EXEC.northwind.dbo.CustOrderHistALFKI
go
execsp_dropserver172.16.0.22,droplogins
GO
RDBMS并非没有局限性。它们难以扩展,需要大量的资源来配置和维护,比如时间、硬件和人力。同样,它们往往遵循峰值性能模型,这就要求系统按照峰值容量来配置可用性,而不考虑典型的数据使用情况。 很多书籍啊,不过个人认为看书太慢,还不如自己学。多做实际的东西,就会遇到很多问题,网上搜下解决问题。不断重复这个过程,在配合sql的F1功能。 始终遗憾SQLServer的登陆无法分配CPU/内存占用等指标数。如果你的SQLServer给别人分配了一个只可以读几个表的权限,而这个家伙疯狂的死循环进行连接查询,会给你的系统带来很大的负担。 XML字段类型更好的解决了XML数据的操作。XQuery确实不错,但是个人对其没好感。(CSDN的开发者应该是相当的熟了!) 从项目平台的选择上讲,我们关心的,应该是一款产品能不能满足任务需求,而不是网上怎么说。 是要和操作系统进行Socket通讯的场景。否则建议慎重! 我们学到了什么?思考问题的时候从表的角度来思考问 原理很简单,对要求长时间计算某一时间点的报表生成和防用户操作错误很有帮助。但是比起Oracle10g的闪回技术还是细粒度不够。可惜! 多走走一此相关论坛,多看一些实例开发,多交流0经验,没什么的,我也是刚学没多久!加油
页:
[1]