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 ...
随机推荐
- 痞子衡嵌入式:蓝牙芯片厂商三强(Qualcomm&CSR, TI, Nordic)产品一览
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是蓝牙芯片三强厂商的芯片. IoT物联网是未来的趋势,半导体厂商作为IoT产业的上游,主要提供核心的无线芯片,蓝牙是比较主流的协议,下面痞 ...
- 分布式系统监视zabbix讲解九之使用snmp监控windows--技术流ken
前言 使用zabbix监控windows主要有两种方法,一种是在windows端安装zabbix-agent客户端工具,安装麻烦.另外一种是使用snmp协议,配置简单快捷.两种配置都可以实现同样的效果 ...
- sql 新增 修改 删除 列操作
IF COL_LENGTH('SYS_Department', 'CreatedBy') IS NOT NULL --判断 SYS_Department 中是否存在 CreatedBy 字段 EXEC ...
- JQuery Dom的基本操作
这是赋值 $("#test").val ("aaa"); 这是取值 string s = $("#test").val (); text( ...
- asp.net-基础-20180321
C#与.NET的关系 C#不是语言,.net是平台.
- PHP中如何给日期加上一个月/天
使用php的strtotime实例:比如现在时间是“2017-07-06”,加一个月. echo date("Y-m-d", strtotime("+1 months&q ...
- hihoCoder编程练习赛49
题目1 : 相似颜色 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在CSS中我们可以用井号(#)加6位十六进制数表示一种颜色,例如#000000是黑色,#ff0000 ...
- Python国内豆瓣源
Python国内豆瓣源 https://pypi.doubanio.com/simple/
- VS2013 添加控制台程序
一.打开vs2013
- gulp es6 转 es5
npm install --save-dev gulp-babel babel-preset-es2015 var babel = require("gulp-babel"); / ...