饿虎岗资源网 Design By www.oxmxm.com
本文实例讲述了Oracle中scott表结构与简单查询的方法。分享给大家供大家参考。具体分析如下:
1、scott用户的表的结构
查看表结构
desc 表名;//desc emp;
emp表:
SQL> desc emp;
名称 是否为空"htmlcode">
select distinct job from emp;
2.查询年薪,起别名,别名不要用单引号括起来
select sal*12 [as] income from emp;
3.简单查询中可以使用"||"连接查询的字段
select empno ||','|| ename from emp;
sql语句中的字符串用单引号表示
select '雇员编号是:'||empno||'姓名是:'||ename||'工资为:'||sal||'职位是:'||job||'!' 雇员信息 from emp;
4.在oracle中数据时区分大小写的
select * from emp where job ='CLERK';
查询不是办事员的雇员信息
select * from emp where job!='CLERK'; select * from emp where job<>'CLERK'; select * from emp where NOT job='CLERK';
5.BETWEEN ……AND 大于等于 小于等于
select * from emp where sal between 1500 and 3000;
也可以求反
select * from emp where sal not between 1500 and 3000;
也可以是日期
select * from emp where hiredate between '01-1月 -1981' and '31-12月 -81';
6. 判断是否为空IS(NOT)NULL
select * from emp where comm Is not null; select * from emp where not comm Is null;
7.IN操作符
select * from emp where empno in (7521,7844,5555); select * from emp where empno not in (7521,7844,5555);
关于NOT IN
如果现在使用了IN操作符,查询范围之中存在了null,不影响查询
select * from emp where empno in (7521,7844,null);
如果现在使用的是NOT IN操作符,如果查询范围之中有了null,则不会有任何的结果返回
select * from emp where not empno in (7521,7844,null); select * from emp where empno not in (7521,7844,null);
8.LIKE子句
匹配符号:
匹配单个字符: _ 0个
匹配任意多个字符:% 0个、一个、多个
查询全部以字母"A"开头的雇员
select * from emp where ename like 'A%';
查询第二个字母为"A"的雇员
select * from emp where ename like '_A%';
查询含有字母为"A"的雇员
select * from emp where ename like '%A%';
查询不含有字母为"A"的雇员
select * from emp where not ename like '%A%'; select * from emp where ename not like '%A%';
LIKE '%%' 表示查询全部数据
select * from emp where empno like '%%'
9.数据的排序
order by 字段 [ASC|DESC][,字段 [ASC|DESC]……];
order by子句必须在where子句之后,在所有sql语句最后
排序的时候可以指明多个排序字段
排序方式有两种:默认(ASC)升序 、DESC(降序)
按照工资进行排序
select * from emp order by sal desc;
先按工资排序,再按照雇佣日期排序
select * from emp order by sal desc,hiredate;
希望本文所述对大家的Oracle程序设计有所帮助。
饿虎岗资源网 Design By www.oxmxm.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
饿虎岗资源网 Design By www.oxmxm.com
暂无评论...
更新日志
2024年09月23日
2024年09月23日
- 国风大师纯音系列《古筝仙子 常静演奏 十指弹一》1CD[FLAC][919MB]
- DasKapital-OneMustHaveChaosInsidetoGiveBirthtoaDancingStar(2024)[24-44.1]WAV
- 王菲.1999-《只爱陌生人》日本东芝版[低速原抓WAV+CUE]
- 张小英1987-金奖金曲第一集[新加坡版][WAV+CUE]
- 鹿晗.2015-重启【海蝶】【FLAC分轨】
- 张芸京.2012-小女孩【金牌大风】【WAV+CUE】
- 余天.2002-雄狮魅力金曲2CD(南方金点系列)【南方】【WAV+CUE】
- 银霞.1982-《结·SAYYESMYBOY》台湾复刻版[WAV+CUE]
- 梁汉文1993-火热动感[引进版][WAV+CUE]
- 梁汉文2008-EDMONDHITS48[香港]3CD[WAV+CUE]
- 国风大师纯音系列《童丽-[渭城曲]》1CD[WAV分轨][593.5MB]
- 国风大师纯音系列《许菱子《烧筝2》古筝曲集》1CD[WAV分轨][1.3GB]
- 王子异《1996 Part.2》[320K/MP3][18.29MB]
- 群星.1994-宝丽金最倾情3CD【宝丽金】【WAV+CUE】
- 乐俊亨.2024-同泪【CharioticMusic】【FLAC分轨】