oracle USING 用法
提问
- using(xx)中可以接多个列吗?
- using(xx)中的列可以接表名或别名吗?
- 在使用using的语句中,select * 可以使用吗?
- 如果表有别名t,select t.* from table1 t , table2 using(xx),t.* 可以使用吗?
- left join, right join, inner join, full outer join 可以和using一起用吗?
我们看下语法就能知道答案了。
只看答案
- using(xx)中可以接多个列,它是一种等值连接,可以转换为 join ... on (x=y and xx=y);
- using(xx)中的列不可以接表名或别名等限定语,默认就是指共同列,不能指定表名;
- 在使用using的语句中,select * 可以使用,* 被扩展的顺序为using中的列,左表中的其它列,右表中的其它列
- 如果表有别名t,select t.* from table1 t , table2 using(xx),t.* 不可以使用,using中的列不能加限定词
- left join, right join, inner join, full outer join 可以和using一起使用,它就是简单的等值连接
inner join 就是 join, outer join有 left, right, full outer join 三种
using的使用条件是两表中列名和类型相同;
natural join更进一步,直接省掉了using,但作用和使用using相似;
inner 和 outer 的区别:内连接只返回匹配行,外连接还返回不满足条件的行;
Syntax
USING ( Simple-column-Name [ , Simple-column-Name ]* )
USING clause definition
The USING clause specifies which columns to test for equality when two tables are joined. It can be used instead of an ON clause in the JOIN operations that have an explicit join clause.
If a column in the USING clause is referenced without being qualified by a table name, the column reference points to the column in the first (left) table if the join is an INNER JOIN or a LEFT OUTER JOIN. If it is a RIGHT OUTER JOIN, unqualified references to a column in the USING clause point to the column in the second (right) table.
When a USING clause is specified, an asterisk (*) in the select list of the query will be expanded to the following list of columns (in this order):
- All the columns in the USING clause
- All the columns of the first (left) table that are not specified in the USING clause
- All the columns of the second (right) table that are not specified in the USING clause
Examples
SELECT * FROM COUNTRIES JOIN CITIES
USING (COUNTRY);
SELECT * FROM COUNTRIES JOIN CITIES
USING (COUNTRY, COUNTRY_ISO_CODE);
SELECT * FROM oe.order_items oi JOIN oe.orders o
USING(order_id);
select t.* from hr.employees t, hr.departments d
where t.department_id = d.department_id;
select * from hr.employees t inner join hr.departments d
using(department_id);
select * from hr.employees t left outer join hr.departments d
using(department_id);
select * from hr.employees t right outer join hr.departments d
using(department_id);
select * from hr.employees t full outer join hr.departments d
using(department_id);
oracle USING 用法的更多相关文章
- ORACLE RETURNING 用法总结
ORACLE RETURNING 用法总结 场景 在存储过程.PL/SQL块里需要返回INSERT.DELETE.UPDATE.MERGE等DML语句执行后的信息时使用,合理使用returning能够 ...
- Oracle instr用法
1:实现indexOf功能,.从第1个字符开始,搜索第1次出现子串的位置 ,) as i from dual; select instr('oracle','or') as i from dual; ...
- Oracle minus用法详解及应用实例
本文转载:https://blog.csdn.net/jhon_03/article/details/78321937 Oracle minus用法 “minus”直接翻译为中文是“减”的意思,在Or ...
- Oracle触发器用法实例详解
转自:https://www.jb51.net/article/80804.htm. 本文实例讲述了Oracle触发器用法.分享给大家供大家参考,具体如下: 一.触发器简介 触发器的定义就是说某个条件 ...
- ORACLE SEQUENCE用法(转)
ORACLE SEQUENCE用法 在oracle中sequence就是序号,每次取的时候它会自动增加.sequence与表没有关系. 1.Create Sequence 首先要有CREATE ...
- [转载]Oracle触发器用法实例详解
本文实例讲述了Oracle触发器用法.分享给大家供大家参考,具体如下: 一.触发器简介 触发器的定义就是说某个条件成立的时候,触发器里面所定义的语句就会被自动的执行. 因此触发器不需要人为的去调用,也 ...
- Oracle数据库用法汇总
一些Oracle数据库用法的小总结 1.使用insert into创建新表 insert into destdb.sub_contract (userid,contractid) select msi ...
- oracle sqlloader 用法
向oracle中导入*.csv文件 1.什么是*.csv,如何得到? 里面存放的是数据表.每行代表数据库表格的一行, 每行中,每两个数据中间由逗号","分割. *.csv可以通 ...
- Oracle Hint 用法
正确的语法是: select /*+ index(x idx_t) */ * from t x where x.object_id=123 /*+ */ 和注释很像,比注释多了一个“+”,这就是 ...
- Oracle REGEXP_INSTR 用法
原文出处 ORACLE中的支持正则表达式的函数主要有下面四个: 1,REGEXP_LIKE :与LIKE的功能相似 2,REGEXP_INSTR :与INSTR的功能相似 3,REG ...
随机推荐
- RabbitMQ系列(二)深入了解RabbitMQ工作原理及简单使用
深入了解RabbitMQ工作原理及简单使用 RabbitMQ系列文章 RabbitMQ在Ubuntu上的环境搭建 深入了解RabbitMQ工作原理及简单使用 RabbitMQ交换器Exchange介绍 ...
- 【golang-GUI开发】项目的编译
在上一篇文章里,我们讲到了安装therecipe/qt(https://www.cnblogs.com/apocelipes/p/9296754.html),现在我们来讲讲如何编译使用了thereci ...
- C#静态成员静态类。
1. 在静态类中,所包含的所有成员必须是静态的.但不是所有静态成员都必须写在静态类中. 实例成员属于具体的对象,静态成员是属于类的.所以访问静态成员的时候不能通过对象来访问,只能通过类名直 ...
- 微服务框架Lagom介绍之一
背景 Lagom是JAVA系下响应式 微服务框架,在阅读本文之前请先阅读微服务架构设计,Lagom与其他微服务框架相比,与众不同的特性包括: 目前,大多数已有的微服务框架关注于简化单个微服务的构建-- ...
- ASP.NET Core中使用Graylog记录日志
以下基于.NET Core 2.1 定义GrayLog日志记录中间件: 中间件代码: public class GrayLogMiddleware { private readonly Request ...
- C#自动关闭弹出提示框
自动关闭弹出提示框(用一个小窗体显示提示信息):例如在一个form窗体中弹出自动关闭的提示框1.首先创建一个弹出提示信息的窗体 AutoCloseMassageBox,在里面拖一个lable控件,去掉 ...
- [PHP]算法-队列结构的PHP实现
题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 思路: 1.php数组完全就能实现 2.array_push 从尾部往里压入元素 3.array_shi ...
- JSJ—编译器与虚拟机哪个重要?
阅读本文约“2分钟” 熟悉Java的朋友都知道虚拟机还有编译器,那么它们各自主要的功能是什么?谁比较重要呢?让我们来了解一下这两位美女的故事. 虚拟机可以说就是Java,她能让程序运行起来. 但是编译 ...
- Java-this
当方法中的参数和类中变量重名时,使用 this.变量 调用成员变量. public class test1 { String name; int age; public void te(String ...
- 12 Linux Which Command, Whatis Command, Whereis Command Examples
This Linux tutorial will explain the three "W" commands. The three "W"s are what ...