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 ...
随机推荐
- 手把手使用Docker搭建SpringBoot微服务镜像
一.环境准备 1.安装好Docker环境的Linux机器(安装教程) 2.准备好SpringBoot项目打包好的可运行jar包 二.编写Dockerfile 1.首先将SpringBoot打包好的ja ...
- SpringMVC学习(四)———— 数据回显与自定义异常处理器
一.数据回显技术 Springmvc默认支持对pojo类型的数据回显,默认不支持简单类型的数据回显 1.1.什么是数据回显? 在信息校验时,如果发生校验错误,那么把校验的数据信息,依然停留在当前页面, ...
- 设置防火强开机自启,以及没有成功的tomcat开机自启
防火墙 如果你的系统上没有安装使用命令安装 #yum install firewalld //安装firewalld 防火墙 开启服务 # systemctl start firewalld.serv ...
- c#使用js上传图片
前几天朋友说用js上传图片过去遇到点问题,于是自己也想写一个demo这里就把自己挖的坑填了. 话不多说上代码 前台就一个file控件加按钮 <!DOCTYPE html> <html ...
- vb.net 多线程運用 ping
Imports System.IOImports System.ThreadingImports System.Diagnostics Public Class Form1 Dim A(254) As ...
- Syncrhonized 和 Lock的区别和使用
相信很多小伙伴们初学多线程的时候会被这两个名词搞晕,所以这里专门介绍这两种实现多线程锁的方式的区别和使用场景 Synchronized 这个关键词大家肯定都不陌生,具体的用法就是使用在对象.类.方法上 ...
- python基础学习(十三)函数进阶
目录 1. 函数参数和返回值的作用 1.1 无参数,无返回值 1.2 无参数,有返回值 1.3 有参数,无返回值 1.4 有参数,有返回值 2. 函数的返回值进阶 例子:显示当前的湿度和温度 例子:交 ...
- 全面掌握Node命令选项
全面掌握Node命令选项 译者按:作为Node.js开发者,有必要全面了解一下节点命令的所有选项,这样在关键时刻才能得心应手. 原文:掌握Node.js的CLI和命令行选项 译者:Fundebug 为 ...
- js 做账单处理
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...
- 2018-06-29 "西游记"主题Python入门示例尝试-数据结构 5.1-5.1.2
(见前: 中文代码示例视频演示Python入门第五章 数据结构 仍然基于官方文档, 欢迎建议(尤其是如何取材). 5. Data Structures - More on Lists 列表详述 > ...