花点时间整理下sql基础,温故而知新.文章的demo来自oracle自带的dept,emp,salgrade三张表.解锁scott用户,使用scott用户登录就可以看到自带的表. #使用oracle用户登录linux [oracle@localhost ~]$ sqlplus / as sysdba; ...... SQL> alter user scott account unlock: 四大语句 DQL语句--select DML语句--insert,upate,delete等(关键…
笛卡尔集 l 笛卡尔集会在下面条件下产生: 省略连接条件 连接条件无效 所有表中的所有行互相连接 l 为了避免笛卡尔集, 可以在 WHERE 加入有效的连接条件. 自连接 select m.last_name,m.email,m.salary from employees e,employees m where e.employee_id = m.manager_id and m.last_name='Chen'; 自己和自己连接,将一张表分为两张表查询使用 非等值连接 SELECT e.l…
--1 数据环境准备 scott 用户下面的emp,dept表 --2 要求 :求平均工资最高的部门编号,部门名称,部门平均工资 select d.deptno,d.dname,e.salfrom(select avg(sal) sal,deptnofrom emp egroup by deptnohaving avg(sal) = (select max(avg(sal)) from emp group by deptno))eleft join dept don e.deptno=d.dep…