唐僧还在拜佛求经路。  

2017年10月4日

摘要: 6-1:子查询简介 6-2: select * from scott.emp where sal=(select MIN(sal) from scott.emp); 范例:查找出公司雇佣最早的雇员; select min(hiredate) from scott.emp 以上查询会返回单行单列的数据 阅读全文
posted @ 2017-10-04 10:31 唐僧还在拜佛求经路。 阅读(290) 评论(0) 推荐(0) 编辑
 
摘要: 现在要求查询出职位的平均每个职位的名称,工资,但是要求显示的职位的平均工资高于2000。 即:按照职位先进行分组,同时统计出每个职位的平均工资 随后要求直显示哪些平均工资高于2000的职位信息 select job,avg(sal) from scott.emp; group by job havi 阅读全文
posted @ 2017-10-04 10:30 唐僧还在拜佛求经路。 阅读(154) 评论(0) 推荐(0) 编辑
 
摘要: 范例:显示所有非销售人员的工作名称以及从事同一工作雇员的月工资总和,并且要求满足从事同一工作雇员的月工资的合计大于5000,显示的结果按照月工资的合计升序排列; 第一步:查询所以人非销售人员的信息。 select * from scott.emp where job<>‘SALESMAN’; 第二步 阅读全文
posted @ 2017-10-04 10:30 唐僧还在拜佛求经路。 阅读(184) 评论(0) 推荐(0) 编辑
 
摘要: 常用的函数: ·:统计个数:COUNT(),根据表中的实际数据量返回结果; ·:求和:SUM(),是针对于数字的统计,求和 ·:平均值:AVG(),各种数据类型都支持 ·:最大值:MAX(),各种数据类型都支持 ·:最小值:MIN(),求出最小值 范例:验证各个函数: select count(*) 阅读全文
posted @ 2017-10-04 10:29 唐僧还在拜佛求经路。 阅读(335) 评论(0) 推荐(0) 编辑
 
摘要: UNION (无重并集):当执行UNION 时,自动去掉结果集中的重复行,并以第一列的结果进行升序排序。 : 查看相同两张表的全部信息,相同的数据则列出一个,不重复。 范例:UNION 操作 select * from scott.emp UNION select * from scott.emp 阅读全文
posted @ 2017-10-04 10:28 唐僧还在拜佛求经路。 阅读(122) 评论(0) 推荐(0) 编辑
 
摘要: 实际上所谓的多表查询指的就是从多张数据表中取出数据并且显示的一种操作。 select * from scott.emp,dept.emp 笛卡尔积存在的原因 实际: SELECT * FROM scott.emp e, scott.dept d WHERE e.deptno=d.deptno; 范例 阅读全文
posted @ 2017-10-04 10:28 唐僧还在拜佛求经路。 阅读(262) 评论(0) 推荐(0) 编辑
 
摘要: IN操作符 select * from scott.emp where empno=7369 or empno=7566 or empno=7788 or empno=9999; select * from scott.emp where empno IN (7369,7566,7788,9999) 阅读全文
posted @ 2017-10-04 10:27 唐僧还在拜佛求经路。 阅读(206) 评论(0) 推荐(0) 编辑
 
摘要: select initcap('guodongdong') from dual; /返回字符串并将字符串的第一个字母变为大写; select initcap(ename) from scott.emp; /针对scott.emp表中的ename开头全部大写。 select lower(ename) 阅读全文
posted @ 2017-10-04 10:26 唐僧还在拜佛求经路。 阅读(419) 评论(0) 推荐(0) 编辑
 
摘要: select ename,hiredate,sysdate from scott.emp ; 可以查询出员工入职到现在的日期 select ename,sysdate-hiredate from scott.emp; 查看在职员工已经多少天; select ename,months_between( 阅读全文
posted @ 2017-10-04 10:26 唐僧还在拜佛求经路。 阅读(1398) 评论(0) 推荐(0) 编辑
 
摘要: select ename,&column2 from scott.emp; 输入sal; /替代标量; select * from &tab; select * from scott.emp where sal> &sal ;2000 select * from scott.emp where en 阅读全文
posted @ 2017-10-04 10:24 唐僧还在拜佛求经路。 阅读(132) 评论(0) 推荐(0) 编辑
 
摘要: 查看缓冲区命令:list 执行save 1.sql 可以吧缓冲区的命令保存下来。 执行 @1.sql可以执行保存下来的内容; show feedback 显示反馈信息,最后一行。 show echo on show arraysize 5000 查看单行输出的行数,默认;15 set arraysi 阅读全文
posted @ 2017-10-04 10:24 唐僧还在拜佛求经路。 阅读(169) 评论(0) 推荐(0) 编辑
 
摘要: s select * from scott.emp where deptno=10; /显示scott.emp表中部门是10的人员信息; select * from scott.emp where deptno=‘10’; /显示scott.emp表中部门是10的人员信息; select * fro 阅读全文
posted @ 2017-10-04 10:23 唐僧还在拜佛求经路。 阅读(176) 评论(0) 推荐(0) 编辑
 
摘要: select * from scott.dept; /查看scott.dept表中的全局信息。 describe scott.emp; /查看scott.dept表详细信息。 select ename from scott.dept; /查看scott.dept表已dname显示出列。 select 阅读全文
posted @ 2017-10-04 10:22 唐僧还在拜佛求经路。 阅读(274) 评论(0) 推荐(0) 编辑