zoukankan      html  css  js  c++  java
  • 视图和实体化视图

    视图与实体化视图
    1. 创建带约束的视图
        SQL> create or replace view emp_sal_view
        as select employee_id,first_name,last_name,salary from employee
        where salary>2000 
        with check option;
    
    2. 创建只读视图
        SQL> create or replace view emp_sal_view
        as select employee_id,first_name,last_name,salary 
        from employee
        with read only;
    
    3. 创建内嵌视图
        SQL> select dname,maxsal,minsal 
        from dept d,(select deptno,max(sal) MaxSal,min(sal) MinSal from emp group by deptno) ds 
        where ds.deptno=d.deptno;
    
        --工资排行前5位
        SQL> select rownum,empno,ename,sal 
        from (select empno,ename,sal from emp  order by sal desc) where rownum<=5;
    
        --工资排行5-10位
        SQL> select rownum,rn,empno,ename,sal from (select rownum rn,empno,ename,sal from (select empno,ename,sal from emp  order by sal desc)) where rn>=5 and rn<=10;
    
            ROWNUM         RN      EMPNO ENAME             SAL
        ---------- ---------- ---------- ---------- ----------
                 1          5       7698 BLAKE            2850
                 2          6       7782 CLARK            2450
                 3          7       7499 ALLEN            1600
                 4          8       7844 TURNER           1500
                 5          9       7934 MILLER           1300
                 6         10       7521 WARD             1250
    
        6 rows selected.
    
        SQL> 

     

     

     

     

  • 相关阅读:
    第一次的作业
    第02组 Alpha冲刺(2/4)
    团队项目选题报告
    第一次个人编程作业
    第二次结对编程作业
    胖子的故事(四)
    关于博客园的聚合问题
    blog是写给谁看的
    ASP.NET Forms 身份验证
    要努力了!
  • 原文地址:https://www.cnblogs.com/vmsysjack/p/12456489.html
Copyright © 2011-2022 走看看