6.2 运算符

 

6.2.1 算术运算符

加 / 减 / 乘 / 除

6.2.2 连接运算符

是用来连接字符串的。跟java中的 + 是一致的。

select 'abc' || ' bcd ' as 连接后的结果 from dual;
select d.dname || ' 部门' from dept d;

6.2.3 比较运算符

> / < / >= / <= / != / <> /IS NULL / Like / Between / In / Exsist

-- 判断 null 值
select * from n5 where s is null;
select * from n5 where s is not null; -- like 模糊查询。慎用,有可能会导致全表扫描,效率低。
-- % 匹配0到多个字符,_ 匹配一个字符
select username from dba_users where username like 'VI_';
select username from dba_users where username like 'SC%';
select username from dba_users where username like '%SC%'; -- in,是 where x = a or x = b or x = c 的一种缩写。下面两条是等价的。
select * from emp where empno in (700, 800, 900);
select * from emp where empno = 700 or empno = 800 or empno = 900;
-- in 后面跟的不一定是逗号分隔的单项,也可能是一个完整的查询语句。
-- 下面两条结果是一致的
-- 这种 in 慎用
select * from emp where deptno in (select deptno from dept where dname = 'SALES');
select a.* from emp a,dept d where a.deptno =d.deptno and d.dname='SALES'; -- between...and
select * from emp where empno between 7800 and 9000;
-- 等同于:
select * from emp where empno >= 7800 and empno <= 9000;

6.2.4 逻辑运算符

and / or / not

not 的优先级 > and 的优先级 > or 的优先级

6.2.5 集合操作符

Union / UnionAll / Intersect / Minus

-- 生成测试数据
create table dept_01 as select * from dept where rownum < 6;
create table dept_02 as select * from dept where rownum < 4;
insert into dept_02 values (98, '小吃部', '斗门');
insert into dept_02 values (99, '外卖部', '香洲');
commit; select * from dept_01
union
select * from dept_02; select * from dept_01
union all
select * from dept_02; select * from dept_01
intersect
select * from dept_02; select * from dept_01
minus
select * from dpet_02;

SQL语句 运算符的更多相关文章

  1. LINQ体验(13)——LINQ to SQL语句之运算符转换和ADO.NET与LINQ to SQL

    运算符转换 1.AsEnumerable:将类型转换为泛型 IEnumerable 使用 AsEnumerable<TSource> 可返回类型化为泛型 IEnumerable 的參数.在 ...

  2. 年终巨献 史上最全 ——LINQ to SQL语句

    LINQ to SQL语句(1)之Where 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子句.Where操 ...

  3. MYSQL 基本SQL语句

    复制表结构 CREATE TABLE 新表 SELECT * FROM 旧表 where 1=2 复制表结构和数据CREATE TABLE 新表 SELECT * FROM 旧表 查询重复数据: se ...

  4. SQL语句

    数据查询:SELECT 以下所有的查询都基于以下的表格: 学生表:STUDENT(SNO,Sname,ssex,sage,sdept); 课程表:course(cno,cnama,cpno,ccred ...

  5. 练习用基础SQL语句

    http://www.cnblogs.com/zxlovenet/p/3728842.html 本文语句大部分SQL语句来自<数据库系统概论>(第四版)王珊&萨师煊 ,是我们上课用 ...

  6. Entity FrameWork 5 增删改查 & 直接调用sql语句

    class="brush:csharp;gutter:true;"> #region 1.0 新增 -void Add() /// <summary> /// 1 ...

  7. SQL语句经典大全

    一.基础 1.说明:创建数据库 CREATE DATABASE database-name  2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- ...

  8. SQL语句大全

    经典SQL语句大全(绝对的经典) 一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份s ...

  9. 个人查阅资料-Sql语句

    SQL分类: DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE) DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT) DCL—数据控制语言(GRAN ...

随机推荐

  1. abap seach help 搜索帮助

    ABAP 的搜索帮助有很多种方法,掌握下面的几种基本差不多了 *&--------------------------------------------------------------- ...

  2. 原生dapper中新增用户后根据用户id,在用户角色表中添加关联数据,事务处理

    var result = 0; var userId = 0; using (var db = _Sql.Connection) using (var tran =db.BeginTransactio ...

  3. swagger-ui升级swagger-bootstrap-ui界面好看到起飞

    如果项目已经集成了swagger,只需要在pom.xml添加,如果你的项目没有集成swagger,自行百度或看最下方的链接 swagger-bootstrap-ui是Swagger的前端UI实现,目的 ...

  4. LeetCode.1005-K次取负数组和最大(Maximize Sum Of Array After K Negations)

    这是悦乐书的第376次更新,第403篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第237题(顺位题号是1005).给定一个整数数组A,我们必须按以下方式修改数组:我们选 ...

  5. 车牌识别1:License Plate Detection and Recognition in Unconstrained Scenarios阅读笔记

    一.WHAT 论文下载地址:License Plate Detection and Recognition in Unconstrained Scenarios [pdf] github 的项目地址: ...

  6. web.xml文件的的param-name

    第一个阶段 配置阶段  web.xml配置,如下图   第二个阶段 初始化阶段  init(ServletConfig config) 1.加载配置文件 获取web.xml文件的的param-name ...

  7. 关于多线程efcore dbcontext 的解决方案。

    首先我们大部分的efcore框架用的DbContext(或者封装的repo)都是底层注入的上下文容器实体. 然后Dbcontext不是线程安全的,也就是说,你在当前线程中,只能创建一个 DbConte ...

  8. idea运行时 Process finished with exit code -1073741819 (0xC0000005)

    问题描述:        idea中启动项目报   Process finished with exit code -1073741819 (0xC0000005) ,如图所示: 问题解决:      ...

  9. c#中抽象类和接口的相同点跟区别

    下面是自己写的一个demo,体现抽象类和接口的用法. using System; using System.Collections.Generic; using System.Linq; using ...

  10. Anaconda配置环境变量+创建虚拟环境+pycharm使用虚拟环境

    Anaconda配置环境变量+创建虚拟环境 配置环境变量 没有添加系统变量,所有系统根本识别不了conda命令,找不到位置,所以添加以下系统变量: 添加对应Anaconda环境变量:(以自己的安装路径 ...