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> 

     

     

     

     

  • 相关阅读:
    java 基础知识
    winform判断一个事件是否已经绑定了事件处理函数
    优质文章
    优质博客
    缩略图的创建
    记录一次错误处理 (xml序列化和反序列化相关)
    文件同步软件
    博客园优质博主集锦
    不错的博文集锦
    cesiumjs
  • 原文地址:https://www.cnblogs.com/vmsysjack/p/12456489.html
Copyright © 2011-2022 走看看