Home > Database > Mysql Tutorial > oracle natural using join 区别

oracle natural using join 区别

WBOY
Release: 2016-06-07 15:32:28
Original
1118 people have browsed it

一.Oracle Natural join create table test_table_A(id number primary key,name varchar(32));create table test_table_B(id number primary key,name varchar(32),des varchar(32));select *from test_table_A;select *from test_table_B;insert into test

一.Oracle Natural join

<span>create table test_table_A(id number primary key,name varchar(32));
create table test_table_B(id number primary key,name varchar(32),des varchar(32));
select *from test_table_A;
select *from test_table_B;
insert into test_table_A(id, name) values(1,'cuiyaonan20 a');
insert into test_table_A(id, name) values(2,'cuiyaonan200 a');
insert into test_table_A(id, name) values(3,'cuiyaonan2000 a');
insert into test_table_A(id, name) values(4,'cuiyaonan2000@163.com a ');

insert into test_table_B values(1,'cuiyaonan20 a','des 1');
insert into test_table_B values(2,'cuiyaonan200 a','des 2');
insert into test_table_B values(3,'cuiyaonan2000 a','des 3');
insert into test_table_B values(4,'cuiyaonan20 b','des 1');
insert into test_table_B values(5,'cuiyaonan200 b','des 2');
insert into test_table_B values(6,'cuiyaonan2000 b','des 3');</span>
Copy after login

在pl/sql中运行如上实例代码

然后执行:

select *from test_table_a natural join test_table_b;
Copy after login
显示结果为:

oracle natural using join 区别

这就是自连接,A表与B表 如果有同名字段,且字段类型一致,就会整合判断内容是否相等相等就做笛卡尔积.


一.Oracle using join

执行如下代码:

select *from test_table_a join test_table_b using(name);
Copy after login

显示结果为:

oracle natural using join 区别

非常明显,using就是相对于natural而言制定了 一列进行匹配(前提条件一致,字段同名,类型一致)


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template