oracle数据库01

一、安装好数据库后其中的几个表的意义:
1)emp表>雇员表(employee)
(表内字段的含义)
                   EMPNO:雇员工号                 Ename:雇员名字
                   job:工作                     sal:工资               comm:津贴
                   deptno:所属部门号    mgr:经理的工号   hiredate:雇佣日期
dept表>部门表
                
                deptno:部门号
                dname:部门名字
                 loc:地址
  salgrade表》公司登记制度表

                grade:等级   losal:最低工资   hisal:最高工资

bonus表》奖金表  

                ename:雇员名字

                job:工作           sal:工资,comm津贴

二、小练习题:
--课后题
--1、查询部门编号为10的员工信息
select * from emp where deptno = 10;

--2、查询年薪大亍3万的人员的姓名、部门编号
select ename,(sal+nvl(comm,0))*12  as 年薪大于三万的人 from emp where (sal+nvl(comm,0))*12>30000;

--3、查询佣金(津贴)为null的人员姓名不工资
select ename from emp where comm is null;

--4、查询工资大于1500 且 and 含有佣金的人员姓名
select ename from emp where sal>1500 and comm is not null;

--5、查询工资大亍1500 或 or含有佣金的人员姓名
select ename from emp where sal > 1500 or comm is not null;  
          
--6、查询姓名里面含有 S 的员工信息 工资、名称 
select ename ,sal from emp where ename like ('%S%');

--7、求姓名以J开头第二个字符O的员工姓名的工资
select sal from emp where ename like ('JO%');

--8、求名字包含%的雇员姓名
select ename from emp where ename like ('%/%%') escape('/');

--9、使用in查询部门名称为 SALES 和 RESEARCH 的雇员姓名、工资、部门编号
select * from emp;
-- 相当于 关联查询了 属于是
select ename, sal, deptno
  from emp
 where deptno in (select deptno
                    from dept
                   where dname = 'SALES'
                      or dname = 'RESEARCH');


--10、使用exists查询部门名称为SALES和RESEARCH 的雇员姓名、工资、部门编号。


select ename, sal, deptno
  from emp
 where exists
 (select deptno
          from dept
         where (dname = 'SALES'
            or dname = 'RESEARCH' )and emp.deptno = dept.deptno);
 

Grade:等级 los二al:最低工资 hisal:最高工资
Deptno: 部门号 Dname: 部门名字 Loc: 地址                                                                                 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值