惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Forbes - Security
Forbes - Security
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
W
WeLiveSecurity
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
Martin Fowler
Martin Fowler
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
WordPress大学
WordPress大学
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
P
Privacy International News Feed
IT之家
IT之家
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY
Hacker News: Ask HN
Hacker News: Ask HN
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Check Point Blog
美团技术团队
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
I
InfoQ
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog

博客园 - 南郭先生kaka

待处理数据的两种模型 nginx重启无法找到PId的解决办法 Wiki版产品需求---产品需求文档到底是谁的?产品到底是谁的? 为什么说private方法是有罪的 XML2JSON 的【net.sf.json.JSONException: nu.xom.ParsingException must be followed by either attribute specifications, ">" or "/>"】问题解决办法 继承的第一原则 致那些不甘寂寞的人 上传File时,浏览器总是添加<pre>的解决办法 使用XSLT转换XML2XML Java 模拟 Http Post 【Code Style】多余判断 java.lang.NoClassDefFoundError错误 Spring 中Quartz配置数据库化 FactoryBean在XML中的依赖注入方法 Camel FTP中文目录解决办法 配置CentOS6.3 NFS Bean复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier) 重读《目标》---目标 重读《目标》---序
WITH AS SQL语句的用法
南郭先生kaka · 2013-04-25 · via 博客园 - 南郭先生kaka

    ‘WITH AS短语也叫做子查询因子(subquery factoring),主要作用是定义一个SQL片段,该片段会被SQL语句中的其它部分应用到。

     主要有这几个作用:

     1.使SQL语句的可读性更高一些。(感觉像编程中的本地变量概念,定义好之后,很多地方都可以使用)。

     2.提高查询效率。特别是对于UNION ALL和子查询被多次引用的时候。如果UNION ALL的很多部分可能相同,如果每个相同的部分都去执行一遍的话,成本很高,而使用WITH AS短语的话,则相同的部分只会执行一遍。执行方式是如果只被调用一次的话,那么和子查询一样,但是一遍以上的话,则会把WITH AS的数据插入到一个临时表中,这样的话,效率就会大幅度的提高。(这点和本地变量的概念还是一样的,本地变量被赋值了之后,后面调用的都是值,而原来的子查询则像方法调用,每次都是调用一遍,这样性能自然会差一些。)

      使用举例:

       with samp as (

       select aaa,bb,ccc from test where dd = ddd

       )  

       select bb from samp 

     注:Oracle是在Oracle 9i release 2开始进行支持的,之前的不支持。使用参考: http://dba-oracle.com/t_oracle_subquery_factoring.htm

           SQLServer则是在2005的时候已经支持了。使用指南:http://technet.microsoft.com/zh-cn/library/ms175972(v=sql.90)

           MySQL现在不支持。可以参考http://stackoverflow.com/questions/1382573/how-do-you-use-the-with-clause-in-mysql