• Oracle基本查询语言


    --1.简单的数据查询语句
    --查询所有的员工的信息
    select * from emp;
    --查询员工的姓名和工作职位
    select ename,job from emp;
    --姓名和工作以中文的形式显示出来
    select ename "姓名",job "工作职位" from emp;
    select ename as "姓名",job as "工作职位" from emp;
    --查询每个员工的职位
    select job from emp;
    --查询每个员工的职位(去掉重复的行记录)
    select distinct job from emp;
    --查询所有员工的基本信息,并且显示效果是:编号是 7369,姓名是SMITH,工作职位是CLERK
    select '编号是' || empno || '姓名是' || ename || '工作职位是' || job 个人信息 from emp;
    --查询所有员工的姓名和年薪
    select ename,sal*12 年薪 from emp;
    select ename, (sal+30)*12+sal 年薪 from emp;
    --2.条件查询
    --查询职工编号是7788的员工信息
    select * from emp where empno = 7788;
    --查询名字是SMITH的员工信息
    select * from emp where ename = 'SMITH';
    --查询工资高于1500的员工信息
    select * from emp where sal > 1500;
    --查询职位是办事员或者是销售人员的全部信息,并且要求这些员工的工资大于1200
    select * from emp where (job = 'CLERK' or job = 'SALESMAN') and sal > 1200;
    --查询员工编号不是7788的员工信息
    select * from emp where empno <> 7788;
    select * from emp where empno != 7788;
    select * from emp where Not empno = 7788;
    --查询姓名中包含A的员工信息(模糊查询)
    --查询以A开头的员工信息
    select * from emp where ename like 'A%';
    --查询名字的第二个字符是A的员工信息
    select * from emp where ename like '_A%';
    --查询名字中只要有A的员工信息
    select * from emp where ename like '%A%';
    --查询所有员工信息
    select * from emp where ename like '%%';
    --查询名字中只要没有A的员工信息
    select * from emp where ename Not like '%A%';
    --3.范围查询
    --查询工资在1500到3000之间所有员工信息
    select * from emp where sal > 1500 and sal < 3000;
    select * from emp where sal BETWEEN 1500 and 3000;
    --[BETWEEN ... and ... ] 是一个闭区间
    select * from emp where sal >= 1500 and sal <= 3000;
    --查询81年入职的所有员工信息
    select * from emp where hiredate between '1-1月-81' and '31-12月-81';
    --表示日期格式是需要用单引号括起来
    --查询职工编号是:7788,7499,7521的员工信息。
    select * from emp where empno = 7788 or empno = 7499 or empno = 7521;
    select * from emp where empno In (7788,7499,7521);
    --查询SMITH,FORD ,KING的信息
    select * from emp where ename = 'SMITH' or ename = 'FORD' or ename = 'KING';
    select * from emp where ename in ('SMITH','FORD','KING');
    --查询职工编号不是:7788,7499,7521的员工信息
    select * from emp where empno not in (7788,7499,7521);
    --如果使用了IN操作符,查询的范围之中有null,不影响查询
    select * from emp where empno in (7788,7499,null);
    --如果使用NOT IN操作符,查询范围之中有null,不会又任何结果返回
    select * from emp where empno not in (7788,7499,null);
    --4.判断是否为空 IS (NOT)NULL
    --查询出所有有奖金的员工姓名与工作职位
    select ename, job from emp where comm is not null;
    --查询出没有资金的员工姓名和工作职位以及入职日期
    select ename,job,hiredate from emp where comm is null;
    --查询工资大于1500,并且有奖金的员工
    select * from emp where sal > 1500 And comm is Not null;
    --查询工资大于2000,或者有奖金员工
    select * from emp where sal > 2000 or comm is not null;
    --查询工资大于1500,并且有奖金的以外的员工
    select * from emp where not (sal > 1500 and comm is not null);
    --5.排序查询
    --查询所有员工姓名,入职日期,工资。结果按入职升序显示
    select ename,hiredate,sal from emp order by hiredate ASC;
    --查询所有员工姓名,入职日期,工资。结果按入职升序显示,工资降序
    select ename,hiredate,sal from emp order by hiredate ASC,sal Desc;

  • 相关阅读:
    Mac部署hadoop3.2.1(伪分布式) ,Hadoop自带的MapReduce程序(wordcount),,,,安装scala,hadoop安装启动问题,Pyspark开发环境搭建,MAC Spark安装和环境变量设置
    使用objdump objcopy查看与修改符号表
    alias, bg, bind, break, builtin, caller, cd, command,
    virtualbox端口转发
    CMake快速入门教程-实战
    内存管理
    http调试工具,linux调试工具
    CSS Background
    RadioButton的check改变的时候
    Docs-->.NET-->API reference-->System.​Web.​UI.​Web​Controls-->Repeater
  • 原文地址:https://www.cnblogs.com/tyzl/p/5532799.html
Copyright © 2020-2023  润新知