小春网

 找回密码
 注册账号
查看: 579|回复: 0
收起左侧

[IT 交流] Oracle 01 基本查询

[复制链接]
发表于 2015-4-16 16:39:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

x
使用scott账户登录数据库后,使用desc 加表名即可查看表结构,如emp表
1.png
查看emp表中deptno(部门编号)为30的员工。select * from emp where deptno=30;
2.png
查看emp表中job(职位)为MANAGER的empno(员工编号)和ename(姓名)。select empno,ename from emp where job='MANAGER';(区分大小写) 3.png

查看emp表中comm(姑且当做奖金)高于sal(工资)的员工.select * from emp where comm >sal;
4.png
查看emp表中deptno(部门)10的NAMAGER(经理)和deptno(部门)20的CLERK(员工)
select * from emp where (deptno=10 and job='NAMAGER') or (deptno=20 and job='CLERK');
5.png
查看emp表中deptno(部门)10,既不是MANAGER(经理)也不是CLERK(员工),但是sal(工资)高于等于2000的人。
select * from emp where deptno = 10 and job not in ('MANAGER','CLERK') and sal >=2000;
6.png
查看emp表中拥有comm(奖金)的员工的job(职位)
select distinct job from emp where comm is not null and comm >0;
7.png
查看emp表中没有comm(奖金)或奖金少于500的员工
select * from emp where comm is null or comm <500;
8.png
在emp表中按照hiredate(雇佣时间),显示ename(员工姓名)
select ename from emp order by hiredate;
9.png

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小春网
常务客服微信
微信订阅号
手机客户端
扫一扫,查看更方便! 快速回复 返回顶部 返回列表