资源描述:
《数据库集合(oracle sql)查询语句》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、数据库集合(oraclesql)查询语句oracle1.select*fromemp;2.selectempno,ename,jobfromemp;3.selectempno编号,ename姓名,job工作fromemp;4.selectjobfromemp;5.selectdistinctjobfromemp;6.selectdistinctempno,jobfromemp;说明:因为雇员编号不重复,所以此时证明所有的列没有重复,所以不能消除掉重复的列.7.查询出雇员的编号,姓名,工作,但是显示的格式:编号是:7369的雇员,姓
2、名是:smith,工作是:clearselect'编号是:'
3、
4、empno
5、
6、'的雇员,姓名是:'
7、
8、ename
9、
10、',工作是:'
11、
12、jobfromemp;8.求出每个雇员的姓名及年薪selectename,sal*12incomefromemp;9.求出工资大于1500的所有雇员信息select*fromempwheresal>1500;10.查询每月可以得到奖金的雇员信息select*fromempwherecommisnotnull;11.查询没有奖金的雇员信息select*fromempwherecommisnull;12
13、.查询出基本工资大于1500同时可以领取奖金的雇员信息select*fromempwheresal>1500andcommisnotnull;13.查询出基本工资大于1500或者可以领取奖金的雇员信息select*fromempwheresal>1500orcommisnotnull;14.查询出基本工资不大于1500或者不可以领取奖金的雇员信息select*fromempwherenot(sal>1500andcommisnotnull);15.查询基本工资大于1500,但是小于3000的全部雇员信息select*fromemp
14、wheresal>1500andsal<3000;16.查询基本工资大于等于1500,但是小于等于3000的全部雇员信息select*fromempwheresal>=1500andsal<=3000;select*fromempwheresalbetween1500and3000;17.查询出在1981年雇佣的全部雇员信息(1981年1月1日到1981年12月31日之间的雇佣的雇员)select*fromempwherehiredatebetween'1-1月-81'and'31-12月-81';18.要求查询出姓名是smith
15、的雇员信息select*fromempwhereename='SMITH';19.要求查询出雇员是7369,7499,7521的雇员的具体信息select*fromempwhereempno=7369orempno=7499orempno=7521;select*fromempwhereempnoin(7369,7499,7521);20.要求查询出雇员不是7369,7499,7521的雇员的具体信息select*fromempwhereempnonotin(7369,7499,7521);21.要求查询出姓名是smith,all
16、en,king的雇员信息select*fromempwhereenamein('SMITH','ALLEN','KING');22.查询出所有雇员姓名中第二个字母包含"M"的雇员信息select*fromempwhereenamelike'_M%';23.查询出雇员姓名中包含字母M的雇员信息select*fromempwhereenamelike'%M%';24.要求查询出在1981年雇佣的雇员信息select*fromempwherehiredatelike'%81%';25.查询工资中包含5的雇员信息select*fromem
17、pwheresallike'%5%';26.查询雇员编号不是7369的雇员信息select*fromempwhereempno!=7369;select*fromempwhereempno<>7369;27.要求按照工资由低到高排序select*frmemporderbysal;select*fromemporderbysalasc;28.要求按照工资由高到低排序select*fromemporderbysaldesc;29.要求查询出20部门的所有雇员信息,查询的信息按照工资由高到低排序,如果工资相等,则按照雇佣日期由早到晚排序
18、.select*fromempwheredeptno=20orderbysaldesc,hiredateasc;30.将小写字母变为大写字母selectupper('hello')fromdual;31.将大写字母变为小写字母selectlower