发布网友 发布时间:2022-04-07 20:38
共3个回答
懂视网 时间:2022-04-08 01:00
(一)基本语句 1、语法SELECT distinct deptno,job,empno FROM EMP order by deptno;
SELECT a.deptno,a.job FROM EMP a; SELECT distinct a.deptno,a.job FROM EMP a order by a.deptno
SELECT a.deptno,a.job FROM EMP a; SELECT distinct a.deptno,a.job FROM EMP a order by a.deptno
select trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333) from dual;
SELECT a.ename,(a.sal*13+nvl(a.comm,0)*13) as "年薪", a.ename||'-'||(a.sal*13+nvl(a.comm,0)*13) as "拼接字串"FROM EMP a ;
SELECT * FROM EMP a WHERE to_char(a.hiredate,'yyyy-mm-dd') > '1981-11-17';
SELECT * FROM EMP a WHERE a.sal between 2000 and 2500;--包含本身,都是闭区间SELECT * FROM EMP a WHERE a.sal >= 2000 and a.sal <= 2500;
SELECT * FROM EMP a WHERE a.empno in (7369,7521,7654);
SELECT * FROM EMP a WHERE a.mgr IS NULL;
SELECT * FROM EMP a WHERE (a.sal >500 or a.job='MANAGER') and a.ename like 'J%';
SELECT * FROM EMP a order by a.sal;--一个条件 SELECT * FROM EMP a order by a.deptno , a.hiredate desc;--2个条件
SELECT a.ename,(a.sal*13+nvl(a.comm,0)*13) as "年薪" FROM EMP a order by 年薪;
SELECT a.ename,(a.sal*13+nvl(a.comm,0)*13) as "年薪" FROM EMP a order by 1;
SELECT max(a.sal),min(a.sal) FROM emp a ; SELECT max(a.sal*13) , min(a.sal*13) FROM emp a ;
SELECT round(avg(a.sal),2),sum(a.sal) FROM emp a ;
SELECT avg(a.comm) FROM emp a ; SELECT sum(a.comm)/count(*) FROM emp a ;
SELECT count(*) FROM emp a ;SELECT count(a.empno) FROM emp a ;
SELECT count(a.comm) FROM emp a ;
SELECT a.ename,a.job FROM emp a WHERE a.sal = (SELECT max(a.sal) FROM emp a);
SELECT a.ename,a.job FROM emp a WHERE a.sal > (SELECT avg(a.sal) FROM emp a);
SELECT avg(a.sal), max(a.sal),a.deptno FROM emp a group by a.deptno;
SELECT avg(a.sal), max(a.sal),a.deptno,a.job FROM emp a group by a.deptno ,a.job order by a.deptno ;
SELECT avg(a.sal) as "平均工资", a.deptno FROM emp a group by a.deptno having avg(a.sal)<2000
Oracle基础(四):单表查询
标签:order by group by having where条件 聚合函数
热心网友 时间:2022-04-07 22:08
在Oracle数据库中,外键是强制实施参照完整性的一种方式,我们约定主键表为主表,外键表为从表,使用外键就意味着一个表中的值在另一个表中也必须出现,指挥在修改时受到影响,在查询时是不受影响的。
或者在查询时也可以禁用外键,语法参考:
热心网友 时间:2022-04-07 23:26
正确答案应该是不受影响的