huawei--创建视图,用到union和union all

CREATE OR REPLACE VIEW vwAgentInfo as select * from tAgentInfo
where (SubCCNo,VDN) =(select SubCCNO,VDN from tUserInfo where Username=user) with read only
/
CREATE OR REPLACE VIEW vwRecordInfo as
select * from tRecordInfo1 where (CallCenterID,VirtualCallcenterID) in (select SubCCNO,VDN from tUserInfo where

Username=user)
union all
select * from tRecordInfo8 where (CallCenterID,VirtualCallcenterID) in (select SubCCNO,VDN from tUserInfo where

Username=user)
union all
select * from tRecordInfo9 where (CallCenterID,VirtualCallcenterID) in (select SubCCNO,VDN from tUserInfo where

Username=user)
union all
select * from tRecordInfo12 where (CallCenterID,VirtualCallcenterID) in (select SubCCNO,VDN from tUserInfo where

Username=user)
/
CREATE OR REPLACE VIEW V_UIDBInfo
AS
  SELECT UIDBVersion UIDBInformation FROM UIDBInfo
UNION
  SELECT UIDBOldVersion FROM UIDBInfo
UNION
  SELECT CreateDate FROM UIDBInfo
UNION
  SELECT ReCreateDate1 FROM UIDBInfo
UNION
  SELECT ReCreateDate2 FROM UIDBInfo
UNION
  SELECT UIDBDEsc FROM UIDBInfo
UNION
  SELECT ContactMan FROM UIDBInfo
/
EXECUTE DBMS_OUTPUT.PUT_LINE('创建视图 v_Rpt_city');

CREATE OR REPLACE VIEW v_Rpt_city(ID, Name)
  AS SELECT ID, Name FROM CITY
UNION
SELECT 0 AS ID, '所有' AS Name FROM DUAL;

CREATE OR REPLACE VIEW V_RPT_CITY(id, name)
AS SELECT 0 as orgaid,'所有' as organame From dual
UNION ALL
SELECT TO_NUMBER(ORGAID),ORGANAME FROM t_pub_orga
WHERE length(orgaid) = 2;

 

你可能感兴趣的:(数据库-视图)