首頁 >資料庫 >mysql教程 >oracle natural using join 区别

oracle natural using join 区别

WBOY
WBOY原創
2016-06-07 15:32:281148瀏覽

一.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>

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

然后执行:

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

oracle natural using join 区别

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


一.Oracle using join

执行如下代码:

select *from test_table_a join test_table_b using(name);

显示结果为:

oracle natural using join 区别

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


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn