使用scott账户登录数据库后,使用desc 加表名即可查看表结构,如emp表
查看emp表中deptno(部门编号)为30的员工。select * from emp where deptno=30;
查看emp表中job(职位)为MANAGER的empno(员工编号)和ename(姓名)。select empno,ename from emp where job='MANAGER';(区分大小写)
查看emp表中comm(姑且当做奖金)高于sal(工资)的员工.select * from emp where comm >sal;
查看emp表中deptno(部门)10的NAMAGER(经理)和deptno(部门)20的CLERK(员工)
select * from emp where (deptno=10 and job='NAMAGER') or (deptno=20 and job='CLERK');
查看emp表中deptno(部门)10,既不是MANAGER(经理)也不是CLERK(员工),但是sal(工资)高于等于2000的人。
select * from emp where deptno = 10 and job not in ('MANAGER','CLERK') and sal >=2000;
查看emp表中拥有comm(奖金)的员工的job(职位)
select distinct job from emp where comm is not null and comm >0;
查看emp表中没有comm(奖金)或奖金少于500的员工
select * from emp where comm is null or comm <500;
在emp表中按照hiredate(雇佣时间),显示ename(员工姓名)
select ename from emp order by hiredate;