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> 

     

     

     

     

  • 相关阅读:
    973. K Closest Points to Origin
    919. Complete Binary Tree Inserter
    993. Cousins in Binary Tree
    20. Valid Parentheses
    141. Linked List Cycle
    912. Sort an Array
    各种排序方法总结
    509. Fibonacci Number
    374. Guess Number Higher or Lower
    238. Product of Array Except Self java solutions
  • 原文地址:https://www.cnblogs.com/vmsysjack/p/12456489.html
Copyright © 2011-2022 走看看