집 >데이터 베이스 >MySQL 튜토리얼 >oracle natural using join 区别
一.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>
然后执行:
select *from test_table_a natural join test_table_b;显示结果为:
这就是自连接,A表与B表 如果有同名字段,且字段类型一致,就会整合判断内容是否相等相等就做笛卡尔积.
一.Oracle using join
执行如下代码:
select *from test_table_a join test_table_b using(name);
非常明显,using就是相对于natural而言制定了 一列进行匹配(前提条件一致,字段同名,类型一致)