zoukankan      html  css  js  c++  java
  • oracle pl/sql中创建视图

    模式:

    create or replace view 视图名 as ...

    举例:

    create or replace view vw_rightpeople
    (rightpeopletypename, rightpeopletype, rightpeopleid, organizetypeno, parentorganizeno, idno, idtype, rightpeoplename, rightpeopleproperty, chairman, resopertype, resstatus, bitspno, address, zip, phoneno, code2, code3, oldpk, description, businesssystemid, createtype, createactiveid, isrestrict)
    as
    select '单位' rightpeopletypename,2 rightpeopletype,organizeno rightpeopleid,organizetypeno,parentorganizeno,idno,idtype,fullname rightpeoplename,type rightpeopleproperty,chairman,resopertype,resstatus,bitspno,
    (select (select region.district from region where regionid=nvl(address.district,0))||street from address where businessno=organizeno and typeno=3 and rownum<2) adress,
    (select to_char(zip) from address where businessno=organizeno and typeno=3 and rownum<2) zip,
    (select CONTACTCONTENT from contact where businessno=organizeno and typeno=3 and rownum<2) phoneno,code2,code3,oldpk,description,businesssystemid,createtype,createactiveid,isrestrict
    from orgorganize a where a.organizeno>100 and a.ORGANIZETYPENO in (41,42,43,44,46,47)
    union all
    select /*+ index(op.pk_orgpeople) +*/ '个人' rightpeopletypename,1 rightpeopletype,participantno rightpeopleid,null,organizeno,idno,idtype,firstname rightpeoplename,BUYERATTR rightpeopleproperty,sex,resopertype,resstatus,bitspno,
    (select (select region.district from region where regionid=nvl(address.district,0))||street from address where businessno=participantno and typeno=4 and rownum<2) adress,
    (select to_char(zip) from address where businessno=participantno and typeno=4 and rownum<2) zip,
    (select CONTACTCONTENT from contact where businessno=participantno and typeno=4 and rownum<2) phoneno,code2,code3,oldpk,description,businesssystemid,createtype,createactiveid,isrestrict
    from orgpeople op where exists (select 1 from orgorganize oo where oo.organizeno=op.organizeno and oo.organizetypeno in (41,42,43,44,46,47));

  • 相关阅读:
    挑战程序设计竞赛 第2章习题 poj 1017 Packets 贪心模拟
    挑战程序设计竞赛 2章习题 poj 2376 Cleaning Shifts
    Leetcode 27. 移除元素 双指针
    Leetcode 26. 删除有序数组中的重复项 双指针
    Leetcode 31. 下一个排列
    webserver 发布问题
    [转]机器学习中的各种距离
    VUE3 + TYPESCRIPT 开发实践总结
    我和ABP vNext 的故事
    ABP Framework 为什么好上手,不好深入?探讨最佳学习姿势!
  • 原文地址:https://www.cnblogs.com/BradMiller/p/1750292.html
Copyright © 2011-2022 走看看