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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 电电儿

FME Cloud 账号申请流程 FME中通过HTMLExtractor向HTML要数据 在windows 2003下安装 django + apache + mod_python arcgis中坐标系统的简单描述 - 电电儿 arcgis 中利用txt坐标文件创建要素的办法,含txt文件详细格式~ Django静态文件配置备忘录 【转】ARCSDE+ORACLE备份 测量坐标系中单个多边形面积解析法计算的程序源代码 - 电电儿 - 博客园 测试oracle with as System.Data.SQLite测试 oracle左右连接的另外表示方法 Oracle 函数大全(字符串函数,数学函数,日期函数,逻辑运算函数,其他函数) Oracle中的Union、Union All、Intersect、Minus inner join,full outer join,left join,right join,cross join - 电电儿 Oracle中的自连接(self join) - 电电儿 ORACLE JOIN - 电电儿 用正则表达式分析正则表达式!求正则表达式组数~ - 电电儿 - 博客园 BoooLee pyretoolkit -- 一个基于python re模块的在线正则表达式测试工具 GDAL 在windows python环境下的安装步骤 - 电电儿
Oracle 中的natural join (自然连接)
电电儿 · 2009-09-13 · via 博客园 - 电电儿

虽然natural join(自然连接)实际上的用的比较少,但实际上这个连接是非常有用的,若能经常使用一下,实际上是非常方便的。

自然连接是在两张表中寻找那些数据类型和列名都相同的字段,然后自动地将他们连接起来,并返回所有符合条件按的结果。

来看一下自然连接的例子。

Select emp.ename,dept.dname

From emp natural join dept;

这里我们并没有指定连接的条件,实际上oracle为我们自作主张的将,emp中的deptno和dept中的deptno做了连接。

也就是实际上相当于

Select emp.ename,dept.dname

From emp join dept on emp.deptno = dept.deptno;

因为这两张表的这两个字段deptno的类型个名称完全相同。所以使用natural join时被自然的连接在一起了。

另外:

1.如果做自然连接的两个表的有多个字段都满足有相同名称个类型,那么他们会被作为自然连接的条件。

2.如果自然连接的两个表仅是字段名称相同,但数据类型不同,那么将会返回一个错误。

3.由于oracle中可以进行这种非常简单的natural join,我们在设计表时,应该尽量在不同表中具有相同含义的字段使用相同的名字和数据类型。以方便以后使用natural join

最后我们在前面举的例子都得到以下的结果:

SQL> Select emp.ename,dept.dname

2 From emp natural join dept;

ENAME DNAME

——————– —————-

SMITH RESEARCH

ALLEN SALES

WARD SALES

JONES RESEARCH

MARTIN SALES

BLAKE SALES

CLARK ACCOUNTING

SCOTT RESEARCH

KING ACCOUNTING

TURNER SALES

ADAMS RESEARCH

JAMES SALES

FORD RESEARCH

MILLER ACCOUNTING