SQL 创建视图
在開發過程中遇到了多表關聯查詢時,由于多表之間有幾個相同的字段,在select * 的時候,有些重復字段值會累加,這樣會導致查詢的結果,在處理數據時會出現問題。所以就采用了視圖。
有兩種類型的數據庫視圖:動態視圖和靜態視圖。動態視圖可以包含一個或兩個表中的數據,并自動包含一個或多個指定表中的所有列。創建或更改相關對象或擴展對象時,動態視圖會自動更新。靜態視圖可以包含來自多個表的數據,并且必須在靜態視圖的 SELECT 和 WHERE 子句中指定這些表中所需的列。創建或更改相關對象或擴展對象時,必須手動更新靜態視圖。
視圖的作用:通過自定義查詢 SQL 生成的虛擬表、邏輯表,作為 select 語句保存在數據字典中,本身并不包含數據。
視圖的語句:create or replace view 視圖名 as select 列名 from 表名1,表名2... where 條件;
CREATE or replace VIEW "ZXQYNWPT3".ZJTXXJR_ALL_INFO as select a."ID",a."PERSONUUID",a."YEAR","SBLX","SQSJ","QYMC","SZSF","SZSFMC","SZS","SZSMC","SZQ","SZQMC","TXDZ","YB","FDDBR","FDDBRDH","FDDBRSJ","LXR","LXRDH","LXRSJ","SJKZR","KGGD","SJKZRGJ","CZ","EMAIL",to_char(zcsj,'yyyy-mm-dd')"ZCSJ","ZCZB","TYSHXYDM","QYGM","SSHY","JTXFLYMC","QYLX","SFKG","KGQY","SFSB","SBQY","SSQK","GPDM","SSJH","SSJHDETAIL","SSJHDETAILQT",a."SFTB","REGISTEREDNO","COMPANYNAME","ACCTTYPE","ADDRESS","CSZT","JHZT","SHSJ","SFZC","THYJ" ,"QZGS2019","QZGS2020","QZGS2021","YFRS2019","YFRS2020","YFRS2021","YYSR2019","YYSR2020","YYSR2021","ZYYWSR2019","ZYYWSR2020","ZYYWSR2021","ZYYWSRZZL2019","ZYYWSRZZL2020","ZYYWSRZZL2021","JLRZE2019","JLRZE2020","JLRZE2021","JLRZZL2019","JLRZZL2020","JLRZZL2021","ZCZE2019","ZCZE2020","ZCZE2021","ZCFZL2019","ZCFZL2020","ZCFZL2021","SJSJ2019","SJSJ2020","SJSJ2021","GQRZ2019","GQRZ2020","GQRZ2021","DYGZ2019","DYGZ2020","DYGZ2021","YHDK2019","YHDK2020","YHDK2021","JNZQ2019","JNZQ2020","JNZQ2021","JWZQ2019","JWZQ2020","JWZQ2021","SFYHDK","XDMZL","DKYT","ZJXQ","RZFF","SCSJ","ZYYWSRZYYSRBZ","PJZZL","QYGLTXRZQK","QYGLTXRZQKQT","HXYWCYXXXTZCQK","HXYWCYXXXTZCQKQT","CPRZQK","CPRZQKQT","SFYDQY","SFSFXM","QYZCFZL","ZDCPGJSCZYL2020","ZDCPGJSCZYL2021","ZDCPGNSCZYL2020","ZDCPGNSCZYL2021","ZDCPCKE2020","ZDCPCKE2021","PPGS2020","PPGS2021","PPSX2020","PPSX2021","JSYJYGJJ","JSYJYSJ","QYJSZXGJJ","QYJSZXSJ","QYGCZXGJJ","QYGCZXSJ","GYSJZXGJJ","GYSJZXSJ","YSZJGZZ","BSHGZZ","HZYXJGMC1","HZYXJGMC2","HZYXJGMC3","YJLYYHDCGJYYQK","YFJFZE2019","YFJFZE2020","YFJFZE2021","YFJFZYYSRBZ2019","YFJFZYYSRBZ2020","YFJFZYYSRBZ2021","YFRYZQYQBZGBZ2019","YFRYZQYQBZGBZ2020","YFRYZQYQBZGBZ2021","YYZSCQQKZS","YYZSCQQKFMZL","YYZSCQQKZWXPZ","YYZSCQQKGJNZWPZ","YYZSCQQKGJXY","YYZSCQQKDLT","SFHDGJKJJ","SFHDGJKJJYEAR","SFHDGJKJJMC","SFHDGJKJJPM","CHINA50TOP","CHINA50TOPYEAR","CHINA50TOPPM","SJLY1","SJLYDETAIL6","SJLYDETAIL7","SJLYDETAIL8","SJLYDETAIL9","SJLYDETAIL10","SJLYDETAIL11","SJLYDETAIL12","SJLYDETAIL13","SJLYDETAIL14","SJLYDETAIL15","SJLYDETAIL16","SJLYDETAIL17","SJLYDETAIL18","SJLYDETAIL19","SJLYDETAIL20","SFGJLYBDB","BDBCPMC","TKBLY","TDGWQYMC","GJLYBDBDETAIL","SFZMDQYZJPT","ZMDQYZJPT1","ZMDQYZJPT2","ZMDQYZJPT3","ZDCPMC","CPLYSJ","ZDCPLB","HYLJQY1","HYLJQY2","HYLJQY3","SYSJLY","SJLY","FBBZZS","FBBZGJZS","FBBZGJIAZS","FBBZHYZS","FBBZMC","XGBMRDCH","XGBMRDCHQT","JWBGQK","JWBGQKZJE","JWBGQKQT","JWFGSQK","JWFGSQKZJE","JWFGSQKQT","JWYFJGQK","JWYFJGQKZJE","JWYFJGQKQT","JWZFZLQK","JWZFZLQKZJE","JWZFZLQKQT","GJZDKJXM","GJZDKJXMMC","GJJJSCXLXM","GJJJSCXLXMMC","QYXXQKJS","FDDBRQM","QZGS2019FILEID","QZGS2019FILENAME","QZGS2020FILEID","QZGS2020FILENAME","QZGS2021FILEID","QZGS2021FILENAME","QYGLTXRZQKFILEID","QYGLTXRZQKFILENAME","HXYWCYXXXTZCQKFILEID","HXYWCYXXXTZCQKFILENAME","ZDCPGNSCZYL2020FILEID","ZDCPGNSCZYL2020FILENAME","ZDCPGNSCZYL2021FILEID","ZDCPGNSCZYL2021FILENAME","YFJFZE2019FILEID","YFJFZE2019FILENAME","YFJFZE2020FILEID","YFJFZE2020FILENAME","YFJFZE2021FILEID","YFJFZE2021FILENAME","YYZSCQQKFILEID","YYZSCQQKFILENAME","SFHDGJKJJFILEID","SFHDGJKJJFILENAME","CHINA50TOPFILEID","CHINA50TOPFILENAME" ,"GQRZ2021FILEID","GQRZ2021FILENAME","PPGS2020FILEID","PPGS2020FILENAME","PPGS2021FILEID","PPGS2021FILENAME","YFJGJSQKFILEID","YFJGJSQKFILENAME","QYXXQKJSFILEID","QYXXQKJSFILENAME" ,"SFFH","SFTY","TJYJ","SFTG","ZSYJ","ZSRBH","ZSRXM",to_char(zssj,'yyyy-mm-dd hh24:mi:ss')"ZSSJ","ZSRJG","ZSRJGMC","ZSRBM","ZSRBMMC"from ZJTXXJR_JBXX a,ZJTXXJR_NRB b, ZJTXXJR_SHXX c where a.id=b.id and a.id=c.id;總結
- 上一篇: JAVA王思聪吃热狗程序_王思聪申请“吃
- 下一篇: CodeForces 584 D.Dim