oracle数据库常用的99条查询语句_北亚企业数据恢

日期:2014-06-07 / 人气: / 来源:网络

1. select * from emp;

2. select empno, ename, job from emp;

3. select empno 编号, ename 姓名, job 工作 from emp;

4. select job from emp;

5. select distinct job from emp;

6. select distinct empno, job from emp;
说明:因为雇员编号不重复, 所以此时证明所有的列没有重复,所以不能消除掉重复的列.

7. 查询出雇员的编号, 姓名, 工作, 但是显示的格式:编号是: 7369 的雇员, 姓名是: smith, 工作是: clear
select '编号是: ' || empno || '的雇员, 姓名是: ' || ename || ', 工作是: ' || job from emp;

8. 求出每个雇员的姓名及年薪
select ename, sal * 12 income from emp;

9. 求出工资大于 1500 的所有雇员信息
select * from emp where sal > 1500;

10. 查询每月可以得到奖金的雇员信息
select * from emp where comm is not null;

11. 查询没有奖金的雇员信息
select * from emp where comm is null;

12. 查询出基本工资大于 1500 同时可以领取奖金的雇员信息
select * from emp where sal > 1500 and comm is not null;

13. 查询出基本工资大于 1500 或者可以领取奖金的雇员信息
select * from emp where sal > 1500 or comm is not null;

14. 查询出基本工资不大于 1500 或者不可以领取奖金的雇员信息
select * from emp where not(sal > 1500 and comm is not null);

15. 查询基本工资大于 1500, 但是小于 3000 的全部雇员信息
select * from emp where sal > 1500 and sal < 3000;

16. 查询基本工资大于等于 1500, 但是小于等于 3000 的全部雇员信息
select * from emp where sal >= 1500 and sal <= 3000;
select * from emp where sal between 1500 and 3000;

17. 查询出在 1981 年雇佣的全部雇员信息(1981 年 1 月 1 日 到 1981 年 12 月 31 日之间的雇佣的雇员)
select * from emp where hiredate between '1-1月-81' and '31-12月-81';

18. 要求查询出姓名是 smith 的雇员信息
select * from emp where ename = 'SMITH';

19. 要求查询出雇员是 7369, 7499, 7521 的雇员的具体信息
select * from emp where empno = 7369 or empno = 7499 or empno = 7521;
select * from emp where empno in(7369, 7499, 7521);

20. 要求查询出雇员不是 7369, 7499, 7521 的雇员的具体信息
select * from emp where empno not in(7369, 7499, 7521);

21. 要求查询出姓名是 smith, allen, king 的雇员信息
select * from emp where ename in('SMITH', 'ALLEN', 'KING');

22. 查询出所有雇员姓名中第二个字母包含 "M" 的雇员信息
        select * from emp where ename like '_M%';

23. 查询出雇员姓名中包含字母 M 的雇员信息
select * from emp where ename like '%M%';

24. 要求查询出在 1981 年雇佣的雇员信息
select * from emp where hiredate like '

作者:管理员




现在致电4006-2991-90 OR 查看更多联系方式 →

Go To Top 回顶部