一、安装好数据库后其中的几个表的意义:
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:
地址